1. Script segment: <% ...%>
2. Expression: <%=. %>
Below, let's give an example to illustrate.
The JSP code is as follows:
<% int =ten; %> <% = a %>
The corresponding translation file, corresponding to the following code:
int a = 10;out.print (a);
As you can see, the expression corresponds to the output statement. Therefore, written <%=a;%> is equivalent to Out.print (A;);
3. Disclaimer: <%! ...%>
We write the following statement in the JSP code:
<% ! int =+; %>
The corresponding translation file, the corresponding code is declared in the Class A member variable
int h = 30;
So, can we declare a class?
Below, let's try to modify the code as follows:
<%test ();%><%! inth= -; void Test () {System.out.println (H* 3); }%>
As you can see, the call to the test () function is no problem, save the Refresh page, and see that the output of the console is 90, so declaring the function is possible.
The corresponding translation file can be seen, declares the function, and calls the method in the service class:
int h = +; void Test () { System.out.println (H * 3); }
...
Test ();
JSP Learning Note II: The scripting syntax of JSP syntax