JSP Syntax (3)

Source: Internet
Author: User
Tags include variables
js| Syntax Declaration

Declaring legitimate variables and methods in a JSP program



JSP syntax

<%! Declaration; [Declaration;] + ...%>

Example

<%! int i = 0; %>

<%! int A, b, C; %>

<%! Circle a = new Circle (2.0); %>

Describe

Declare the variables and methods that you will use in your JSP program. You must do the same, or you will make mistakes.



You can declare multiple variables and methods at once, as long as the ";" At the end of the line, of course, these statements in Java if legitimate.



When you declare a method or variable, be aware of some of the following rules:



The statement must be ";" The end (Scriptlet has the same rule, but the expression is different).

You can directly use the declared variables and methods that are included in the <% @ Page%>, and do not need to declare them again.

A declaration is valid only in one page. If you want to use a few statements for each page, it's best to write them in a separate file and include them with <%@ include%> or <jsp:include > elements.


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.