Scriptlet and annotation in JSP, and JSPscriptlet Annotation
Scriptlet and comment in JSP.
Scriptlet:
In JSP, most of them are composed of Scriptlet. A script applet is embedded in html code and directly contains java code. There are three types of code:
<%> Define local variables and write the statement <%! %> Defines global variables. You can write a class or method <% = %> Expression output to output a variable or a specific value.
The first <%> Common Code is as follows:
int i = 10 ; int j = 20 ; out.println(i * j) ; out.println("
"+ (++ I) + "")
Type 2 <%! %> Is generally used to define global variables.
<%! int i = 10 ; int j = 20 ;%><% out.println(i * j) ; out.println("
"+ (++ I) +" "); %>
Note that java code and html are mixed,(out.println("
")
Third <% = %> example:
<% int i = 10 ;%><%=i%><%="hello World!!!"%>
If you use too much in the program, the code will be very messy. Therefore, in the new version of jsp, A scriptlet tag is provided. Its syntax is as follows:
Java code
----------
String url = "www.baidu.com";
<%=url%>
Notes in jsp:
Jsp supports two types of annotation syntax operations. One is display annotation, which can be seen by the client, and the other is implicit annotation, which cannot be seen by the client.
Display notes:
Implicit annotation:
// Single line comment/**/multi-line comment <%-comment-%>, jsp comment
For example:
<% // Single line comment provided in Java. The client cannot see the multiline comment provided in/* Java, and the client cannot see */%> <% -- or -- %>'
Note:
In development, implicit annotation is not sent to the client. In jsp, try to replace out. println () with the expression output statement as much as possible ()