JSP reference (4) script element [scriptlet]

Source: Internet
Author: User
Block declaration description
Declares a script language variable or method. The content must be a complete and valid statement written in the language defined by the page command. The embedded JSP object is invisible to the declared element. The variables declared here are processed as member variables of the compilation unit.
 
Syntax
Syntax 1 JSP page
<%! Declaration %>

Syntax 2 JSP document
<JSP: Declaration> declaration </jsp: Declaration>

 
Example
<%! Int globalcounterter = 0%>
<JSP: Declaration>
Void doit (){}
</Jsp: Declaration>

Expression block description
You can add the result of executing a script expression to the response. The START character and end character must be a complete and valid expression. Built-in objects are visible in expressions.
 
Syntax
Syntax 1 JSP page
<% = Expression %>

Syntax 2 JSP document
<JSP: expression> Expression </jsp: expression>

 
Example
<% = Globalcount ++ %>
<JSP: expression> "Hello world! "</Jsp: expression>

Script block description
It can be used to embed script code snippets into pages. All the small scripts on the page must be combined to form legal script language statements. All built-in objects are visible in small scripts.
 
Syntax
Syntax 1 JSP page
<% Scripting code fragment %>

Syntax 2 JSP document
<JSP: scriptlet> scripting code fragment </jsp: scriptlet>

 
Example
<% For (INT I = 0; I <10; ++ I) {%>
<B> Hello wrold! </B> <br>
<% }%>

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.