Experience points on the declaration in the JSP

Source: Internet
Author: User

Declaration in JSP:

There are two ways to declare in a JSP: one is <% intcount=0%>, and the other is <%! Intcount=0%>, now talk about the second kind.

1, test conditions:

Suppose there are two pages test1.jsp and test2.jsp have the following code:

<%! Intcount=0%>

<%intCount+=1;

Out.print ("The" +intcount+ "the number of people entering this page!");

%>

2. Test environment: jrun3+jdk1.2

3, test results:

• This intcount as long as it is on the same page, is equivalent to an ASP in a application, each user share this variable, and initialization intcount=0 only when the first user log in execution.

• But different pages do not affect each other.

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.