JSP as the foundation of web development, has its important position, so proficient in JSP grammar and application has become a top priority.
First we start with the basic syntax of JSP: (The following is from Li Xinghua Video manuscript collation)
Scriptlet Introduction
Script is a scripting applet, like the previous out.println () This statement is abbreviated in <%%>, it is obvious that the abbreviated sentence is a script.
The most important part of the JSP is the Scriptlet (script applet), all Java programs embedded in the HTML code must use the
Scriplet, there are three kinds of scriplet code in JSP
The first kind: <%%>, in this scriplet can define local variables, write statements;
The second type: <%! %>, in this scriplet can define global variables, methods, classes;
The third type: <% =%>, for outputting a face or a specific content.
The first kind of script<%%>
To insert pure Java code into a JSP page in <%%>
The second kind of script<%!%>
The main function is to define the global variables, methods, classes, and assume the following definitions of methods and classes to validate
<%!
public static final String info= "www.baidu.com";
%>
<%!
public int Add (int x,int y) {return
x+y;
}
%>
<%!
Class person{
private String name;
private int age;
Public person (String Name,int age) {
this.name=name;
this.age=age;
}
Public String toString () {return
"name=" +this.name+ "; age=" +
this.age;
}
}
%>
<%
out.println ("