JSP9 large built-in objects

Source: Internet
Author: User
Tags session id server port

JSP9 large built-in objects

JSP9 built-in objects:
The Out object is used to output various data
reuest object encapsulates various information from the client
response object encapsulates response information for the server
exception object encapsulates exceptions and error messages that occur during program run

page object points to the current JSP program itself
session object is used to hold session information (that is, it can share data between different requests from the same user) The
application object represents the context of the current application and can share information among different users
The span style= "FONT-SIZE:16PX" >pagecontext object provides access to all of the JSP objects and namespaces


Out object:
Out.println and Out.newline are both line-wrapping, but are not displayed on the page, but are displayed in the code
Out.getbuffersize () Gets the current buffer size
Out.getremaining () Gets the number of bytes remaining in the current buffer


The request object encapsulates the requested information sent by the client to the server, including user-submitted form information and other information about the client, such as COOKIE,IP, host name

The Request.getmethod () method is used to output the method name of the request
Request.getrequesturi () The URI string used to get the request
Request.getprotocol () the protocol used to obtain the request
Request.getservername () to get the name of the requesting server
Request.getserverport () to get the requested server port
REQUEST.GETREMOTEADDR () to get the IP address of the client
Request.getremotehost () to get the host name of the client
Request.getparameter () to get the value of the form submission
Request.getparametervalues () get the parameter array
Request.setattribute () saves these parameter information to the request object
Request.getattribute () Gets the parameter information from the request object


Response Built-in objects

Response.setheader ("Cache-control", "No-cache");
SetHeader Set Header information Cache-control a cache policy for setting Web page data, set to No-cache to indicate that data content is not stored

Response.setintheader ("Refresh", 2)
Set Web pages to refresh automatically every two seconds

Response.sendredirect ("url") implement page jump


Session Object
Session.getid () get the session ID
Session.getcreationtime Gets the session creation time
Session.getlastaccessedtime () Gets the last access time for the session
Session.getmaxinactiveinterval () Gets the expiration time of the session


The Application Object represents the current application, it exists in the memory space of the server, the application will automatically generate a Application object once it is started, and if the application is not closed, the Application object will be preserved forever. The Application object will not be destroyed until the application is closed.

The Application object has a longer life cycle than the session object, and these features of the Application object provide convenience for multiple users to share some global information, such as sharing the current number of people online, and so on.

Application.getserverinfo () Get information about the server
Application.getservletcontextname () returns the current app name
Application.getvirtualservername () Gets the name of the host


The Config object represents the configuration information for the current JSP program
Config.getinitparameter () Gets the specified initialization information

The Page object is a bit like the this pointer in Java, which 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 information describing the exception

PageContext Object
It is a feature integrator for all other objects in a JSP page, and it can be used to access all other built-in objects

Pagecontext.getout () Gets the Out object
Pagecontext.setattribute ("1", "Xiongda", Pagecontext.session_scope);
Session.getattribute ("1")
Use the PageContext object to select a range of key-value pairs to save

JSP9 large built-in objects

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.