1. JSP annotations
There are two main types of annotations in JSPs:
Explicit Comment: <!--HTML Comment, client visible--(heavier transport burden, minimal use)
implicit annotations:
Format one://single-line comment
Format two:/* */single-line or multiline comment
Format three: <%--jsp comment, client not visible--%> JSP Comment
Example:
Write a JSP file that contains the above three types of annotations
2. Scriptlet (Script applet)
All Java programs that are embedded in HTML code must be marked with Scriptlet.
Scriptlet includes: small scripts, declarations, and expressions, which are described separately below.
(1) Small script: <%java code%>
can write various statements in our Java application methods, including defining variables, but cannot write methods.
Reason: The code will be converted into a method body in a class by the JSP engine, if the method is written, it is equivalent to the method body
Declares a method, so you cannot write a method in a small script.
For example:
In the JSP page, ask for 1-100 summation and output in the page:
(2) Statement: <%! Method%>
define global constants, write methods, but not directly in <%! %> write any ordinary statement, because this part will be the JSP
The engine is converted into a method in a class.
Note: JSP built-in objects cannot be used in this section.
For example:
Declares a method that formats a date, and the call displays the current date.
(3) Expression: <%=%>
output A variable or a specific content.
For example:
It is better to use Out.print () and expressions to print a table of 10 rows and 10 columns on the page, respectively.
Out.print () Output:
Expression output: More concise, the foreground code is more structured, so recommend this way.
Basic knowledge of JSP syntax