When each JSP page is accessed for the first time, the JSP engine translates it into a Servlet source program, and then Compile this Serlvet source program into a Servlet class file.
Then the Web container (Servlet engine) loads, interprets and executes the Servlet program in the same way as calling a normal Servlet program.
Variables that have been declared, we don’t need to declare them ourselves.
There are 9 hidden objects in total.
HttpServletRequest request
HttpServletResponse response (response is almost never called in a JSP page any method)
PageContext pageContext: The context of the page. You can get the other 8 implicit objects from this object, and you can also get other objects of the current page. Information
HttpSession session: A conversation between the browser and the server
ServletContext application: Represents the current Web application
ServletConfig config: ServletConfig object of the Servlet corresponding to the current JSp (almost not used)
JspWriter out: out.println() can print the string directly to the browser
Object page: points to the current JSP A reference to the corresponding Servlet object, but because of the Object type, only methods of the Object class can be called (almost not used)
Exception exception: In the statement where the page directive is declared isErrorPage="true" can only be used. <% page isErrorPage="true" %>
pageContext, request, session, application (the scope of the attribute is smaller than to large)
<%= xxx %>
<%! %>The java code in will be inserted outside the jspServlet method of the Servlet, So the JSP declaration can be used to define the Servlet program that the JSP page is converted into static code blocks, member variables and methods.
Because JSP implicit objects are declared within the jspServlet method, so these implicit objects cannot be used in JSP declarations.
<%-- --%>
The above is the detailed content of Getting Started with JSP Basics. For more information, please follow other related articles on the PHP Chinese website!