JSP9 large built-in object

JSP9 large built-in object

JSP9 built-in objects: The
out object is used to output various data
. The reuest object encapsulates various information from the client. The
response object encapsulates the response information of the server. The
exception object encapsulates the exception and error information that occurs during the running of the program. The
config object encapsulates the application The page object of the configuration information
of the program points to the session object of the current JSP program itself,
which is used to save session information (that is to say, it can share data between different requests of the same user). The
application object represents the context of the current application and can be used in different users. The pageContext
object provides access to all JSP objects and namespaces


out object:
out.println and out.newline are both line breaks, but they will not be displayed on the page, but only displayed in the code
out.getBufferSize() Get the current buffer size
out.getRemaining() Get the number of bytes remaining in the current buffer


The request object       encapsulates the request information sent by the client to the server, including the form information submitted by the user and other information of the client, such as cookie, ip, hostname

The request.getMethod() method is used to output the method name of the request
request.getRequestURI() is used to obtain the URI string of the request
request.getProtocol() is used to obtain the protocol used by the request
request.getServerName() is used to obtain the request server The name
request.getServerPort() is used to get the requested server port
request.getRemoteAddr() is used to get the IP address of the client
request.getRemoteHost() is used to get the hostname of the client
request.getParameter() is used to get the value of the form submission
request .getParameterValues() Get the parameter array
request.setAttribute() Save the parameter information in the request object
request.getAttribute() Get the parameter information in the request object


response built-in object

response.setHeader("Cache-Control","no-cache");
setHeader sets the header information cache-control is used to set the caching strategy of web page data. Setting it to no-cache means that the data content will not be stored

response.setIntHeader("Refresh",2)
sets the web page to automatically refresh every two seconds

response.sendRedirect("url") realizes page jump


Session object
session.getId() to get the id of the session
session.getCreationTime to get the creation time of the session
session.getLastAccessedTime() to get the last access time of the session
session.getMaxInactiveInterval() to get the expiration time of the session


The application object represents the current application, which exists in the memory space of the server. Once the application is started, it will automatically generate an application object. If the application is not closed, the application object will be kept until the application is closed. object will be destroyed

Compared with the session object, the application object has a longer life cycle. These characteristics of the application object provide convenience for multiple users to share some global information, such as sharing the current online number, etc.

application.getServerInfo() gets the server information
application.getServletContextName() returns the current application name
application.getVirtualServerName() gets the name of the host


The config object represents the configuration information of the current JSP program
config.getInitParameter() Get the specified initialization information

 

The page object is a bit like the this pointer in java, it points to the current JSP page itself
page.toString()
page.getClass() returns the current object class
page.hashCode() returns the hashCode value of the current object

 

When the exception object needs to be used, set the isErrorPage property in the page compilation directive to true

exception.getMessage() returns a message describing the exception

 

The pageContext object
is the functional integrator of all other objects in the JSP page, using it to access all other built-in objects

pageContext.getOut() Get the out object
pageContext.setAttribute("1","xiongda",pageContext.SESSION_SCOPE);
session.getAttribute("1")
Use the pageContext object to select the range of key-value pairs saved

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325331559&siteId=291194637