Features of built-in objects:
1. Provided by the JSP specification, without being instantiated by the creator.
2. Implementing and managing through the Web container
3. All JSP pages can be used
4. Available only in expressions or snippets of script elements (<%= using built-in object%> or <% using built-in objects%>)
Nine large built-in objects and common methods:
1.request Object (Request information Javax.servlet.http.HttpServletrequest)
Method name |
Description |
IsUserInRole |
Determine if the authenticated user belongs to a member group |
GetAttribute |
Gets the value of the specified property, as if the property value does not exist return null |
Getattributenames |
Gets the collection of all property names |
GetCookies |
Get all Cookie objects |
Getcharacterencoding |
Gets the character encoding of the request |
Getcontentlength |
Returns the length of the request body, as indeterminate returns-1 |
GetHeader |
Gets the specified name header value |
Getheaders |
Gets all values of the specified first name header, an enumeration |
Getheadernames |
Gets the name of all the headers, an enumeration |
getInputStream |
Returns the request input stream to get the data in the request |
GetMethod |
Get a way for clients to transfer data to the server side |
GetParameter |
Gets the specified name parameter value |
Getparameternames |
Gets the name of all parameters, an enumeration |
Getparametervalues |
Gets all values for the specified name parameter |
Getprotocol |
Gets the protocol name that the client sends data to the server side |
GetQueryString |
Gets the query string that is passed to the server in the Get method |
Getrequesturi |
Gets the client address that issued the request string |
Getremoteaddr |
Get the IP address of the client |
Getremotehost |
Get the name of the client |
GetSession |
Get and request a related session |
getServerName |
Get the name of the server |
Getserverpath |
Get the path to the client request file |
Getserverport |
Get the port number of the server |
RemoveAttribute |
Delete a property in the request |
SetAttribute |
Set the specified name parameter value |
2.response Object (Response Javax.servlet.http.HttpServletResponse)
Method name |
Description |
Addcookie |
Add a Cookie Object |
AddHeader |
Add an HTTP file to specify header information |
Containsheader |
Determines whether the specified name HTTP file header information exists |
Encodeurl |
Using SessionID to encapsulate URLs |
Flushbuffer |
Forces the current buffer content to be sent to the client |
GetBufferSize |
return buffer size |
Getoutputstream |
Returns the output stream object to the client |
Senderror |
Send error message to client |
Sendredirect |
Send the response to another location for processing |
setContentType |
Set the MIME type of the response |
SetHeader |
Sets the HTTP header information for the specified name |
3.session Object (Session javax.servlet.http.HttpSession)
Method name |
Description |
GetAttribute |
Gets the property of the specified name |
Getattributenames |
Gets the name of all the attributes in the session, an enumeration |
GetCreationTime |
Returns the creation time of the session |
GetId |
Get the session identifier |
Getlastaccessedtime |
Returns the last time the request was sent |
Getmaxinactiveinterval |
Returns the time-to-live unit of Session object 1 per thousand seconds |
Invalidate |
Destroying session objects |
IsNew |
Whether each request will produce a new session object |
RemoveAttribute |
Delete the property of the specified name |
SetAttribute |
Sets the property value of the specified name |
4.application Objects (Application Javax.servlet.ServletContext)
Method name |
Description |
GetAttribute |
Gets the property value of the specified name in the Application object |
Getattributenames |
Gets the name of all the properties in the Application object, an enumeration |
Getinitparameter |
Returns the initial parameter value of the specified name in the applied object |
Getservletinfo |
Returns the current version information in the servlet compiler |
SetAttribute |
Sets the attribute value for the specified name in the Application object |
5.out objects (data flow javax.servlet.jsp.jspWriter)
Method name |
Description |
Print or println |
Output data |
NewLine |
Output line break characters |
Flush |
Output buffer Data |
Close |
Turn off the output stream |
Clear |
Clears the data in the buffer but does not output to the client |
Clearbuffer |
Clears data from buffer, outputs to client |
GetBufferSize |
Get buffer size |
Getremaining |
Get space that is not occupied in the buffer |
Isautoflush |
is auto-output |
6.pageContext Object (page context Javax.servlet.jsp.PageContext)
Method name |
Description |
Forward |
Redirect to another page or servlet component |
GetAttribute |
Gets the property value of the specified name in a range |
Findattribute |
Search for properties of specified names by range |
RemoveAttribute |
Delete a property of a specified name in a range |
SetAttribute |
Sets the attribute value of a specified name in a range |
GetException |
Returns the current exception object |
Getrequest |
Returns the current Request object |
GetResponse |
Returns the current Response object |
Getservletconfig |
Returns the ServletConfig object of the current page |
Getservletcontext |
Returns all page-Shared ServletContext objects |
GetSession |
Returns the session object for the current page |
7.config Object (servlet configuration information Javax.servlet.ServletConfig)
Method name |
Description |
Getservletcontext |
Returns the Environment object of the servlet being executed |
Getservletname |
Returns the name of the servlet being executed |
Getinitparameter |
Returns the initial parameter value for the specified name |
Getinitparameternames |
Returns all the initial parameter names in the JSP, an enumeration |
8.page object (An instance of the current JSP, java.lang.object)
It means that the JSP is compiled into a servlet, which can be used to invoke methods defined in the Servlet class
9.exception object (Run-time exception, java.lang.Throwable)
The result of the called error page can only be used in the error page.
That is set in the page directive: <% @page iserrorpage= "true"%>
Javaweb--jsp nine large built-in Objects complete summary