Today, I reviewed the JSP script elements and comments, and wrote the case. After debugging, the overall summary is as follows,
1. JSP statement:
<%! Statement %>
The variable in the declarative statement is a global variable. When multiple users execute this JSP page, the variable is shared.
For example:
<Head>
<Title> JSP Demo </title>
</Head>
<Body>
<%! Int I = 1% type = "codeph" text = "/codeph">
</Body>
2. JSP Scriptlets:
<% Java code %>
The JSP Scriptlets can contain multiple statements, such as methods, variables, and expressions;
For example:
<Head>
<Title> JSP Demo </title>
</Head>
<Body>
<%
String str = "Hello, xiaomo! ";
Out. println (str );
%>
</Body>
3. JSP expressions:
<% = Java code %>
In a simple form of output, there must be a value that can be output. The code in the expression is executed first, and then converted to a string to be displayed on the page.
For example:
<Head>
<Title> JSP Demo </title>
</Head>
<Body>
<% String str = "Hello, xiaomo! "; %>
<% = Str %>
</Body>
4. JSP comments:
<! --> HTML comment, which is displayed on the client;
<% -- %> JSP comment, not displayed on the client;