One, the JSP implied object
1,jsp suppressed objects are instances of a set of classes that are managed by a JSP container load.
* JSP suppressed objects are defined in the _jspservice method, so they can only be used in expressions, scriptlet.
2,jsp hidden objects are grouped into 4 categories:
* Input and Output objects: HttpServletRequest request, httpservletresponse response, jspwriter out;
* Scope Communication object: HttpSession session, ServletContext application, PageContext PageContext;
* Servlet object: Page of object, ServletConfig config;
* Wrong object: Throwable's exception;
Code fragment in 3,servlet:
... ...
public void _jspservice (HttpServletRequest request, httpservletresponse response)
Throws Java.io.IOException, Servletexception {
PageContext pagecontext = null;
HttpSession session = NULL;
ServletContext application = null;
ServletConfig config = null;
JspWriter out = null;
Object page = this;
JspWriter _jspx_out = null;
PageContext _jspx_page_context = null;
... ...
}
Second, the input Output object: Control the input and output of the page;
1,httpservletrequest Request: The encapsulation of the client requesting information.
* Scope:
A request to a response phase. At this stage, the forwarding and page-containing objects are shared.
The request object is re-created for each request.
2, HttpServletResponse response: Encapsulation of server response information.
* Used to set response headers, cooike, and other response information.
3,jspwriter: Output data as a stream of characters, a cached version of PrintWriter, using the Buffer property of the page directive to set the size of the buffer.
* Several methods related to caching operations:
Flush: Refreshing buffer;
Isautoflush: Determines whether an out object is automatically refreshed. Settings are automatically refreshed in the buffer property of the page directive.
Clear and Clearbuffer: Clears the contents of the buffer. If the buffer is "refreshed", the former throws an IO exception and the latter does not.
* Code fragment in the servlet:
out = Pagecontext.getout ();
_jspx_out = out;
Third, the scope of Communication objects: JSP page and servlet communication information;
1, PageContext PageContext: Provides a unified portal to access other suppressed objects and their properties and their properties to maintain data sharing between different components of the same page.
* JAVAX.SERVLET.JSP.PAGECONTEXT;
* Scope:
The scope of the page. Each page and request has a different PageContext object.
When you include a page by using the include directive, the included file shares the PageContext object. Jsp:include action is not possible.
For such a property, put it in the request.
Servlet and JSP pages do not share PageContext objects.
* Access, setting and removing properties for other suppressed objects: scope is PageContext constant.
GetAttribute (string name, int scope);
SetAttribute (string name, int scope);
RemoveAttribute (string name, int scope);
The RemoveAttribute (string name) method removes the specified properties for all range classes.
* Search for all properties specified in the range, in the order of Page,request,session,application.
Findattribute (string name);
* The code fragment in the servlet:
.....
private static final Jspfactory _jspxfactory = Jspfactory.getdefaultfactory ();
.....
public void _jspservice (HttpServletRequest request, httpservletresponse response)
.....
pagecontext = _jspxfactory.getpagecontext (this, request, response, NULL, True, 8192, true);
pagecontext _jspx_page_context = null;
_jspx_page_context = PageContext;
application = Pagecontext.getservletcontext ();
Config = Pagecontext.getservletconfig ();
Session = Pagecontext.getsession ();
out = Pagecontext.getout ();
... ...
_jspxfactory.releasepagecontext (_jspx_page_context);
... ...
}
2,httpsession session: Encapsulates conversation information for the current request and implements session tracking.
* Code fragment in the servlet:
Session = Pagecontext.getsession ();
2,servletcontext Application
* Scope: All pages share an object while the Web application is running.
* Code fragment in the servlet:
application = Pagecontext.getservletcontext ();
Four, Servlet object: JSP page environment information;
1,object page: A reference to a Servlet object during the current request.
* You can use the page to access the class members and methods of the generated servlet. The page instruction is the application of the object.
* Scope:
Created each time a JSP page is requested, and is destroyed after the request is forwarded or responded to.
Objects of this scope can only be accessed in the page where the object is created.
The PageContext object belongs to the page range.
* Code fragment in the servlet:
Object page = this;
2,servletconfig Config:servlet initialization information.
Five, Wrong object: processing the page error;
* Java.lang.Throwable Exception: Represents an exception that occurs when a JSP page runs.
* * This object can only be used in the error page (page directive iserrorpage=true pages).