The JSP compiler guidelines and instruction components have five types. After JSP1.0, most of the JSP is contained in a single tag that ends. The new JSP1.1 specification has been published and is also compatible with XML.
The compiler guidelines for the five types of JSPs are as follows:
1. Compiler guidelines
2. Predefined
3. Operational type
4. Program code
5. Annotations
Below we analyze a simple JSP page. You can create another directory in the JSWDK examples directory where the file name can be arbitrary, but the extension must be. jsp. As you can see from the code listing below, the JSP page has essentially the same structure as a few more Java code than a normal HTML page. Java code is added to the HTML code by <% and%> notation, and its main function is to generate and display a string from 0 to 9. At the front and back of this string are some text that is output through the HTML code.
Copy Code code as follows:
< html>
< head>< title>jsp Page </title>< body>
<%@ page language= "java"%>
<%! String str= "0"; %>
<% for (int i=1 i < i++) {
str = str+ i;
}%>
JSP output before.
Copy Code code as follows:
After the JSP output.
Copy Code code as follows:
This JSP compiler page can be divided into several sections to analyze.
The first is the JSP directive. It describes the basic information about the page, such as the language used, whether the session state is maintained, whether buffering is used, and so on. The JSP instruction ends with <%@ beginning,%>. In this case, the directive "<% @pagelanguage =" java "%>" simply defines the Java language used in this example (Currently, Java is the only supported language in the JSP specification).
The next is the JSP declaration. A JSP declaration can be viewed as a place to define variables and methods at this level of class. The JSP declaration ends with <%! beginning,%>. As in this case, "<%! Stringstr= "0";%> defines a string variable. After each declaration, you must have a semicolon, just as you would declare a member variable in a normal Java class.
The code block between <% and%> is the Java code that describes the processing logic of JSP pages, as shown in the For loop in this example.
Finally, the code between <%= and%> is called a JSP expression, as shown in "<%=str%>" in this example. A JSP expression provides a simple way to embed a JSP-generated value into an HTML page.