3.1,JSPOverview
JSP pages are actually running in the JSP container. Servlet containers are generally also JSP containers. For example,Tomcat is a servlet/jsp container.
The first time a JSP page is requested, theservlet/jsp container does two things:
1, jsp page converted to a jsp page implementation class, which is an implementation javax.servlet.jsp.jsppage interface or its sub-interface javax.servlet.jsp.httpjsppage Span style= "Font-family:times New Roman" >java jsppage Yes so that each jsp page becomes a servlet
2. If the conversion succeeds, theservlet/jsp container will compile the Servlet class.
3.2, Notes
JSP pages can use two types of notes:
1, JSP notes. Describe the role of the page
2, html/xhtml notes. These will be sent to the browser.
JSP notes begin with <%-- and End with --%> . For example, here is a JSP Note:
<%--Retrieve products to display--%>
JSP comments are not sent to the browser, nor can they be nested.
Html/xhtml notes are not processed by the container, but are sent to the browser. One of the uses of html/xhtml notes is to identify JSP pages:
<!--this IS/JSP/STORE/DISPLAYPRODUCTS.JSPF-
This is especially useful when working with applications with many JSP fragments. Developers can easily find out which JSP The HTML code section generates by looking at the HTML source code of the browser. Page or which fragment.
3.3, an implicit object
Jsp 9 An Implicit object: request , response , out , session , application , config , pagecontext , page , exception
3.4, Directives
Directive is the first JSP syntax element that indicates How a JSP converter should convert a JSP page into a Servlet 's command. The most important are the two:page and include.
3.4.1,pageinstruction
The syntax of the Page directive is as follows:
<%@ page attrubute1= "value1" attribute= "value2" ...%>
The space between @ and page is optional,attribute1,attribute2 , and so on are The properties of the page directive. The following is a List of the properties of the page directive:
Import. Specifies one or more Java types to import for use by the Java code on this page . For example:import="Java.util.List".
Session. A value of true indicates that the page participates in session management; When the value is false , the session is not involved Management. The default value is true, which means that if a javax.servlet.http.HttpSession instance has not been previously , the call The JSP page will always create one.
Buffer. Specifies the size, in kilobytes, of the buffer for an implicit object out.
Autoflush true false response Span style= "font-family: Song body; Font-size:12px "> flush method to flush the buffer. Therefore, an exception is thrown when the buffer overflows.