JSP-scriptlet (small script)

Source: Internet
Author: User
In JSP, most of the scripts are small. Program The so-called script applet directly contains Java Code . In JSP, scriptlet is divided into three types: 1. <%>: defining local variables, compiling Statement 2. <%! %>: Defines global variables. Class and method 3 <% = %>: expression output, which is used to output variables or a specific value.
 
<%IntI = 10;IntJ = 20; Out. println (I*J); Out. println ("<H1>" + (++ I) + ");%>

1. I found that no matter how the above programs refresh the page, the content of I is still 11, which is fixed because it is re-declared every time.

<%!IntI = 10;IntJ = 20;%> <%Out. println (I*J); Out. println ("<H1>" + (++ I) + ");%>

2. In the program, you only need to refresh the page and add it by yourself, because it declares a global variable and only declares it once.

 
<%IntI = 10;%> <% = I %> <% = "Hello world !!! "%>

3. Expression output: Output a variable or a specific value.

 

Http://lixinghua.blog.51cto.com/421838/101379

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.