JSP small Knowledge Simple introduction _jsp programming

Source: Internet
Author: User

Hide Annotations

Write in the JSP program, but not to the customer.

JSP syntax
<%--Comment--%>
Example:

Copy Code code as follows:

<%@ page language= "java"%>
<body>
<%--This comment'll is visible in the page source--%>
</body>

Describe

Characters marked with hidden annotations are ignored when the JSP is compiled. This annotation is useful when you want to hide or annotate your JSP program. The JSP compiler does not compile the statements between <%--and--%>, it will not appear in the client's browser, nor will it be seen in the source code.

Between <%----%>, you can write any comment statement, but you cannot use "--%>" if you want to use "--%>".
================================================================
Statement
Declaring legitimate variables and methods in a JSP program

JSP syntax
<%! Declaration; [Declaration;] + ...%>
Example

Copy Code code as follows:

<%! 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.
==================================================================

An expression
Contains an expression that conforms to the JSP syntax

JSP syntax
<%= expression%>
Example

Copy Code code as follows:

<font color= "Blue" ><%= map.size ()%></font>
<b><%= numguess.gethint ()%></b>.

Describe
An expression element represents an expression that is defined in a scripting language, automatically converted to a string after it is run, and then inserted into the location of the JSP file to display the expression. Because the value of this expression has been converted to a string, you can insert the expression in one line of text (in the same way as an ASP).
When you use an expression in your JSP, keep the following points in mind:
You cannot use a semicolon (";") as the terminator of an expression. But the same expression used in scriptlet needs to end with a semicolon! View Scriptlet
This expression element can include any expression that is valid in the Java Language specification.
Sometimes an expression can also be a property value of another JSP element. An expression can become complex, and it may consist of one or more expressions, the order of which is left to right.

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.