JSP nine built-in objects, the four scopes

JSP nine built-in objects

Built-in objects created in java script is not required, it can be used directly in the object.

①request: representative requested (by far)
the HttpServletRequest object. Inside is the servlet request

常用属性:
setCharacterEncoding
getParameter
setAttribute
getAttribute
getSession
getRequestDispatcher

②response: represents the response (with very little)
HttpServletResponse object. Inside is the servlet response

setCharacterEncoding
setCotentType
sendRedirect
getWriter
getOutputStream

③session: HttpSession objects (will use)
the HttpSession object is inside the servlet session scope objects

setAttribute
getAttribute

④application: ServletContext represents a target application (with less)
the ServletContext object is servlet = super.getServletContext file application inside the ServletContext ();
the ServletContext web.xml of the entire package is.

⑤pageContext:
scope object: the role of the scope of the current page
setAttribute
getAttribute
operation of other objects scope
setAttribute (property name, property value, the scope identifier)
getAttribute (attribute name, scope identifies)
a common identifier Scope :
PageContext.PAGE_SCOPE
PageContext. REQUEST_SCOPE
PageContext.SESSION_SCOPE
PageContext.APPLICATION_SCOPE
can get the other eight built-in objects
pageContext.getRequest ()
pageContext.getResponse ();
pageContext.getSession ();
pageContext.getServletContext (); -> appllication
...
pages and pages contain jump
pageContext. include ( "/ jsp pages path");
pageContext.forward ( "/ JSP page path");
typically used to custom label

⑥page: represents the current page, similar to java in this

⑦config: ServletConfig objects, save some startup JSP configuration information
ServletConfig that the object is a package of servlet configuration items.

⑧out: stream object, may want to output the page content (using less)
PrintWriter object. Servlet is inside PrintWriter out = response.getWriter ();

⑨exception: on behalf of the exception object, can only be used in isErrorPage = "true"

/

Four Scope

GetAttribute scope (small to large) object
pageContext: the role of the entire page, after the jump, the failed
request: the role when the second request, effectively forward, redirect invalid, the refresh invalid
session: the role when the sign
application: the role of the entire web application

Guess you like

Origin blog.csdn.net/MacWx/article/details/92573968