request, response, out, session, Application, config, PageContext, page, exception.
a . Request :
This object encapsulates the information submitted by the user, and by invoking the corresponding method of the object, the encapsulated information can be obtained. Even if the object can be used to obtain user-submitted information.
For example : request.getparameter ("MyVar");
two . Response Object :
Respond dynamically to customer requests and send data to the client. For example:
PrintWriter out = Response.getwriter ();
Out.println ("hello!");
Three. Session object:
1.What isSession: Session Object is a JSP built-in objects , it was in the firstJSPthe page is automatically created when it is loaded, and session management is complete.
open a browser from a client and connect to the server to start, to the client close the browser to leave the end of this server, known as a session.
when a client accesses a server, it may be repeatedly connected between several pages of the server, repeatedly refreshing a page,
The server should know by some means that this is the same customer, which requires Session Object .
2 . Sessionobject thatID: When a customer accesses a server on the firstJSPpage,JSPEngine produces aSessionobjects,
also assign aStringtype ofIDnumber,JSPThe engine will alsoIDsent to the client, stored inCookiesin which
thisSessionone by one corresponding relationships are established between the object and the customer. When a customer accesses another page that connects to the server,
no longer assigned to the customer newSessionobject until the client closes the browser,Server-Sidethe customer'sSessionobject is not canceled,
And the conversation correspondence with the customer disappears. When the customer re-opens the browser and then connects to the server, the server creates a new one for the customerSessionobject.
Four. aplication object:
1. What isApplication:
This is generated when the server is started.Applicationobject, when a customer browses between pages of the site visited, thisApplicationobjects are the same until the server shuts down.
but withSessionThe difference is that all of the customer'sApplicationobjects are the same, that is, all customers share this built -inApplicationobject.
2. ApplicationCommon methods for objects:
(1) public void SetAttribute (String key,object obj):the parameterObjectthe specified objectobjAdd toApplicationobject,
and specify an index keyword for the added object.
(2) public Object getattribute (String key):GetApplicationObject that contains the keyword.
Five. out object:
outThe object is an output stream used to output data to the client. outobject is used for the output of various data.
Six. page object:
correspondingThis keyword . JSPWeb page itself
pageobject is the current page after the convertedServletthe instance of the class. From the convertedServletclass, you can see this relationship in the code:
Object page =this;
in theJSPpage, rarely usedpageobject.
Seven. Config Object
Javax.servlet.ServletConfiginstance that represents theJSPconfiguration information.
the usual methods areGetinitpararneter (String Paramnarne)andGetinitpararneternarnes ()and other methods.
in fact,JSPThe page is usually not configured and there is no configuration information. Therefore, the object is moreServletare valid.
Eight:exception object:
java.lang.Throwableinstance, which represents exceptions and errors in other pages.
only if the page is an error handling page, that is, the compile instructionpageof theIserrorpageproperty istrue, the object is not available for use.
the usual methods areGetmessageoand thePrintstacktraceoand so on.
Nine:PageContext Object
Javax.servlet.jsp.PageContextinstance of the object that represents theJSPA page context that allows you to access shared data in a page.
the usual methods areGetservletcontextoand theGetservletconfigoand so on.
//UsePageContextsets the property, which defaults to thepagewithin range
pagecontext.setattribute ("page", "Hello");
//UseRequestsets the property, which defaults to theRequestwithin range
Request.setattribute ("Request", "Hello");
//UsePageContextset the property toRequestin the range
Pagecontext.setattribute ("Request2", "Hello", pagecontext.request_scope);
// UseSessionset the property toSessionin the range
Session.setattribute ("session", "Hello" l;
//UsePageContextset the property toSessionin the range
Pagecontext.setattribute ("Session2", "Hello", pagecontext.session_scope);
//UseApplicationset the property toApplicationin the range
application. SetAttribute ("app", "Hello");
//UsePageContextset the property toApplicationin the range
Pagecontext.setattribute ("app2", "Hello", Pagecontext.applworkcation_scope);
9 built-in objects for JSPs