JSP program design (2)-JSP basic syntax (2)-Declaration

Source: Internet
Author: User

Declare valid variables and methods in JSP programs

JSP syntax

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

Example

<%! Int I = 0; %>
<%! Int A, B, C; %>
<%! Circle A = new circle (2.0); %>

Description

Declare the variables and methods you will use in the JSP program. You must do the same. Otherwise, an error will occur.

You can declare multiple variables and methods at a time, as long as they end with ";". Of course, these declarations are valid in Java.

When declaring methods or variables, pay attention to the following rules:

The declaration must end with ";" (scriptlet has the same rule, but the expression is different ).
You can directly use declared variables and methods included in <% @ Page %> without declaring them again.

A statement is valid only on one page. If you want to use some declarations for each page, you 'd better write them into a separate file and include them with the <% @ include %> or <JSP: Include> element.

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.