Learn java--from 0. Introduction to various auxiliary elements from JSP to servlet transformation

Source: Internet
Author: User
Tags html notes

1. Indicates the element, <%@ indicates the element [attribute = value]*%> which indicates that the element includes page, include, and Tablib three. where property = value can have many pairs. Where page is used to tell the container how to interpret the current JSP page, the following three are the most commonly used page properties: Include is used to include other JSP pages, such as the HTML can be separated from the head and tail, He is then included in various pages through the include indicator element. The JSP is static and is an indicator during compilation. Examples are as follows:    subsequently there are <jsp:include xxx> tags, which are dynamic and run-time.     by default, a container uses a Servlet object to handle requests from different users, so code written in a JSP must be aware of thread safety issues. 2.affirmsyntax of the element:<%!class member declaration or method declaration%>
As the name implies, the so-called declaration element is used to define a class member variable or method in a JSP file, and the code within the declaration element is generally translated into a member variable or method of the Servlet class. Examples are as follows:

 3. The scriptlet element, whose syntax is as follows,
<% Java Statement%>
you can write multiple statements in it, and all statements within <% XXX%> will be translated inside the _jspservice () method.
    Scriptlet can be disabled and can be configured in Web. XML, <scripting-invalid>true</scripting-invalid>
It is bad habit to include a lot of scriptlet on the webpage, the good habit is to try El or jstl tag to eliminate scriptlet;
The sample code is as follows:

 4. Expression Elements
<%= xxxx%>
The result of the expression operation is directly part of the Web page,    such as <%= new Date ()%>       5. Three different types of annotations
    the comments of the #,java itself,
    #,html notes, <!--xxxx----
    #,jsp's notes, <%--xxxxx--%>
#, there are many different types of implicit objects, they can only be used in <% xxx%>, <%= xxxx%>, can no longer <%! xxx%> internal use, because the implicit object is actually the _jspservice method inside the local Variable.        #, because <%%> has a special meaning in JSP, if you want to output these two symbols on the HTML interface, you need to use the translation characters
  #,<% = &lt;%
  #,%>=%&gt;



Learn java--from 0. Introduction to various auxiliary elements from JSP to servlet transformation

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.