JSP-Understanding JSP Basics

Source: Internet
Author: User

Understanding JSP
1. JSP script snippet
In Jsp, java code needs to be nested in <% [java code-> script fragment] %>. No nested content is called the template element of Jsp.
Script fragments can be accessed from each other. They can be incomplete, but multiple fragments must be combined into a complete java statement.
<% If (true) {%> A template element <% }%> is equivalent to the content of the template element in <% if (true) {}%> {}.
2. JSP script expression
<% = Variable or expression %> You can directly output program data to the client.
Variables or expressions in JSP script expressions cannot be followed by semicolons 【;]
3. JSP Declaration
<%! Java code %>
4. JSP comments
<% -- Comment -->
 
5. JSP commands
<% @ Command attribute name = "value" %>
The main Commands are page Commands include commands.
----------
When the JSP Engine translates a JSP page into a Servlet program, it ignores the commented content on the JSP page.
But <! -Html annotation --> is sent to the client.
 
Out. println in Jsp code; output the result string generated by other Java program code to the client
The System. out. println statements print them to the command line window.

Each text segment on both <%> and <%> of each line on the JSP page is converted into an out. write statement that uses the text as the parameter,
The java code in the JSP script snippet (a piece of java code in <%>) is moved to the corresponding position in the jspService method intact,
A JSP expression (Content in <% = and %>) is an out. print statement that is converted to a variable or expression.

The declared code is converted Out Of The _ jspService method.
Therefore, JSP declarations can be used to define static code blocks, member variables, and methods of Servlet programs converted from JSP pages.

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.