JSP page <%@%>, <%! The meaning of%>, <%%>, <%=%>, <%----%> __java

Source: Internet
Author: User

Just learn JSP students may not clear JSP and HTML page relationship, in fact, can be a JSP page as a special HTML page, just inserted in the HTML page Java program section and JSP tag, JSP page in the server after the execution or return an HTML page to the browser.

Here is how to insert Java code in the JSP page, in fact, mainly remember the role of several symbols on the line:

1, <%@%>: This represents instructions, mainly used to provide the entire JSP page-related information, and to set the JSP page related properties, such as the Web page encoding format, syntax, information and so on. There are currently three kinds of instructions: page, include, Taglib. The page instruction is the most complex JSP instruction, and its main function is to set the properties and related functions of the entire JSP page. The include directive represents the introduction of a package at JSP compile time, which is static, and the introduced file can be a JSP page, an HTML page, a text file, or a Java program. Taglib allows users to customize new labels.

2, <%! %>: is used to declare a method that declares the application's global variables or the current page. For example:

<%! String name = "Zhangsan"; %>
<%! public void Show () {
	System.out.print (name);
} %>
3, <%%>: Used to insert Java code. For example:

<%if (Count > 0) {%>
    <jsp:include page= "grrc.jsp" ></jsp:include> 
<%}%>

4, <%=%>: Used to insert a Java expression. For example:

<div id= "Divtop" >
	<jsp:include page= "<%=port.getf_link" (). Trim ()%> ">
	<jsp:param name= "id" value= "<%=id%>"  />
	<jsp:param name= "SkinID" value= "<%=skinidstr%>"/>
	< Jsp:param name= "width" value= "<%=widthstr%>"/>
	</jsp:include>
</div>

5, <%----%>: Used to annotate JSP code. For example:

<%--/src/images/hwbgzdh.jpg" alt= "ss"/>--%>


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.