JSP's built-in objects are all Servlet API interface instances. Create instances in the _ jspService method of the Servlet generated by the JSP script (why is there no exception object? The exception object can be used only when the isErrorPage attribute of the page command in the page is true .), Therefore, we can use these built-in objects in JSP output expressions.
_jspService( javax.servlet.http.HttpServletRequest request, = = java.lang.Object page = = =
1: application Object 1: Data is shared among multiple JSPs in the entire Web system. '2: Web application access parameter configuration.
<%!%><%"counter",String.valueOf(++%>
<%=application.getAttribute("counter") %>
Access the application variable in Servlet:
service(HttpServletRequest request, HttpServletResponse response) "text/html;charset=GBK"=="counter"
Obtain the Web application configuration parameters:
<%application.getInitParameter("driver");application.getInitParameter("url");application.getInitParameter("username");application.getInitParameter("password");%>
Web. xml:
<context-param> <param-name>driver</param-name> <param-value>com.mysql.jdbc.Driver</param-value> </context-param>
2: output stream of the out object page
Service (HttpServletRequest request, HttpServletResponse response) "text/html; charset = GBK" = "nice to see and hate"
3: config object
Indicates the configuration information of the current JSP page, which is used less in JSP and more in Servlet.
4: exception object
Throwable instance, part of the JSP page exception mechanism.
JSP generates Servlet. All JSP scripts and static HTML will be placed in the try block. An exception occurs. If errorPage is specified, it will be forwarded to the specified error page, if not, an exception occurs on the current page.
5: pageContext object
Indicates the context to access Shared data between JSP. You can use the pageContext object to access objects in the range of application, request, session, and page.
GetAttribute (String name) gets the name attribute of page
GetAttribute (String name, int scope)
<%%>
6: request object
The request object encapsulates a user request. The request object is an instance of the HttpServletRequest interface.
GetParameter ()
GetHeader ()
<%<String> headerNames === request.getParameter(= request.getParameterValues(%>
The GET request contains Chinese characters.
<% String queryString = String decoderString = java.net.URLDecoder.decode(queryString, = decoderString.split(%>
7: response object
1: The response object generates a non-character response.
2: redirection.
<%"target.jsp"%>
3: Add Cookie
<%= request.getParameter("username"= Cookie("username"6*24*60*60%>
<%=("username"%>
By default, the Cookie value cannot contain Chinese characters. However, you can use URLEncoder to encode Chinese characters and save the encoded value as the Cookie value. When reading cookies, you should first read them and then use URLDecoder to decode them.
8: session Object
<%"username", "harry"%>
9: page Object