Jsp built-in object, jsp built-in

Source: Internet
Author: User

Jsp built-in object, jsp built-in
Jsp built-in objects are member variables that can be used in JSP page scripts (Java program slices and Java expressions) without being declared and created. The built-in component JSP has the following nine basic built-in components (which can correspond to the six internal components of ASP): The request information of the request object client is encapsulated in the request object, it can be used to understand the customer's needs and then respond. It is an instance of the HttpServletRequest class. The request object has a request domain, that is, the object remains valid until the client completes the request. Serial number method description 1 object getAttribute (String name) returns the attribute value of the specified attribute 2 Enumeration getAttributeNames () returns the Enumeration of all available attribute names 3 String getCharacterEncoding () returns the length of the Request body (in bytes) 5 String getContentType () to obtain the MIME type of the Request body 6 ServletInputStream getInputStream () get the binary stream 7 String getParameter (String name) of a row in the Request body. Return the parameter value of the specified name parameter 8 Enumeration getParameterNames () returns the enumerated 9 String [] getParameterValues (String na 10 String getProtocol () returns the protocol type and version 11 String getScheme () used in the request, for example, http. 12 String getServerName (), such as https and ftp, returns the Host Name of the server that receives the request 13 int getServerPort (), and returns the port number 14 BufferedReader getReader () used by the server to accept the request () returns the decoded Request body 15 String getRemoteAddr (), returns the Client IP address 16 String getRemoteHost (), returns the client host name 17 void setAttribute (String key, object obj) sets the attribute property value 18 StringgetRealPath (String path) and returns a virtual path. The true path 19 String request. getContextPath () returns the context path response object contains information about the response to the customer request, but it is rarely used directly in JSP. It is an instance of the HttpServletResponse class. The response object has a page scope, that is, when accessing a page, the response object in the page can only be valid for this access, and the response object of other pages is invalid for the current page. The serial number method specifies the character encoding 2 ServletOutputStream getOutputStream () used to return a response. A binary output stream 3 PrintWriter getWriter () returns an object 4 void setContentLength (int len) that can output characters to the client. Sets the Response Header Length 5 void setContentType (String type) and sets the response MIME type 6 sendRedirect (java. lang. string location) the session object requested by the client is a session between the client and the server. The session object starts when the client is connected to a WebApplication on the server until the client is disconnected from the server. It is an instance of the HttpSession class. The Session object is a JSP built-in object. It is automatically created when the first JSP page is loaded to complete Session management. A session starts when a client opens a browser and connects to the server, and ends when the client closes the browser and leaves the server. When a client accesses a server, it may switch between several pages of the server. The server should know in some way that this is a customer and the Session object is required. The session object has the session scope. The serial number method indicates that 1 long getCreationTime () returns the SESSION creation time 2 public String getId () returns the unique ID 3 long getLastAccessedTime () set by the JSP Engine during SESSION Creation () returns the client's last request time in this SESSION 4 int getMaxInactiveInterval () returns the interval between two requests this SESSION was canceled (MS) 5 String [] getValueNames () returns an array of 6 void invalidate () containing all the available attributes of this SESSION to cancel the SESSION. If the SESSION is unavailable, 7 boolean isNew () is returned to a SESSION created by the server, whether the client has added 8 void removeValue (String name) to delete the attribute 9 void set specified in the SESSION MaxInactiveInterval () sets the interval between two requests this SESSION is canceled (MS) soft quotes jsp built-in object is a java class object that can be used in jsp pages. The out object is an instance of the JspWriter class. It is a common method for outputting content to the client. It indicates that 1 void clear () clears the content of the buffer 2 void clearBuffer () clear the current content of the buffer 3 void flush () Clear the stream 4 int getBufferSize () returns the buffer size in bytes. If no buffer is set, it is 05 int getRemaining () returns the remaining number of buffers available. 6 boolean isAutoFlush () indicates whether to automatically clear the buffer or throw an exception when the returned buffer is full. 7 void close () the page Object of the output stream page Object points to the current JSP page itself, a bit like this pointer in the class, which is java. lang. the instance serial number method of the Object class indicates that 1 class getClass returns the class 2 int hashCode () of this Object and returns the hash code 3 boole of this Object. An equals (Object obj) checks whether the Object is equal to the specified Object. 4 void copy (Object obj) copies the Object to the specified Object. 5 Object clone () clone this Object 6 String toString () convert this Object to a String Object 7 void every Y () Wake up a waiting thread 8 void every yall () wake up all waiting threads 9 void wait (int timeout) so that a thread is waiting until the timeout ends or is awakened 10 void wait () keep a thread waiting until it is awakened. 11 void enterMonitor () locks the Object. 12 void exitMonitor () locks the Object. The application Object of the application Object implements data sharing and storage between users. Put global variables. It starts from the start of the server until the server is closed. During this period, this object will always exist. In this way, the object can be connected between users or between users, you can perform operations on the same attribute of this object. Operations on this object attribute anywhere will affect access by other users. The startup and shutdown of the server determine the life of the application object. It is an instance of the ServletContext class. The serial number method indicates that 1 Object getAttribute (String name) is returned to the named attribute value 2 Enumeration getAttributeNames (). Enumeration of all available attribute names is returned. 3 void setAttribute (String name, Object obj) set attribute value 4 void removeAttribute (String name) delete a property and its attribute value 5 String getServerInfo () return JSP (SERVLET) engine name and version 6 String getRealPath (String path) returns the actual path of a virtual path 7 ServletContext getContext (String uripath). returns the application Object 8 int getMajorVersion () of the specified WebApplication, and returns the server-supported Ser. The maximum vlet API version 9 int getMinorVersion () returns the minimum Servlet API version supported by the server 10 String getMimeType (String file) returns the MIME type of the specified file 11 URL getResource (String path) return the URL path 12 InputStream getResourceAsStream (String path) of the specified resource. Return the input stream 13 RequestDispatcher getRequestDispatcher (String uripath) of the specified resource) returns the RequestDispatcher object of the specified resource. 14 Servlet getServlet (String name) returns the Servlet15 Enumeration getServlets () of the specified name. returns the enumerative 16 En of all servlets. Umeration getServletNames () returns the enumeration of all Servlet names 17 void log (String msg) writes the specified message to the Servlet's log file 18 void log (Exception exception, String msg) write the stack track and error message of the specified exception to the log file 19 void log (String msg, Throwable throwable) of the Servlet) write stack tracing and Throwable exception description information to the Servlet Log File exception object is an exception object. When an exception occurs during a page running, this object is generated. To apply this object to a JSP page, you must set isErrorPage to true; otherwise, compilation fails. He is actually a java. lang. throwable Object Sequence Number Method description 1 String getMessage () returns a message describing an exception 2 String toString () returns a brief description of the exception message 3 void printStackTrace () display exceptions and stack trajectories 4 Throwable FillInStackTrace () rewrite execution stack trajectory the pageContext object provides access to all objects and namespaces on the JSP page, that is to say, he can access the SESSION where this page is located, or take a property value of the application where this page is located. It is equivalent to a set of all functions on the page, and its class name is also called pageContext. The serial number method indicates that 1 JspWriter getOut () returns the JspWriter stream (out) used by the current client in response to the current client. 2 HttpSession getSession () returns the HttpSession object (session) on the current page) 3 Object getPage () returns the Object (page) of the current page 4 ServletRequest getRequest () returns the ServletRequest Object (request) 5 ServletResponse getResponse () of the current page () returns the current page's ServletResponse object (response) 6 Exception getException () returns the Exception object (exception) of the current page 7 ServletConfig getServletConfig () returns the current page's ServletConfig object (config) 8 ServletContext getServletContext () returns the current page's ServletContext Object (application) 9 void setAttribute (String name, Object attribute) set attributes and attribute values 10 void setAttribute (String name, Object obj, int scope) set the attribute and attribute value within the specified range 11 public Object getAttribute (String name) Get the attribute value 12 Object getAttribute (String name, int scope) get the attribute value 13 public Object findAttribute (String name) within the specified range to find an attribute and return the starting attribute value or NULL14 void removeAttribute (String name) delete an attribute 15 void removeAttribute (String name, int scope) delete an attribute 16 int getAttributeScope (String name) within a specified range returns the range of a property 17 Enumeration getAttributeNamesInScope (int scope) returns the enumerated 18 void release () Attribute names available within the specified range to release resources occupied by pageContext 19 void forward (String relativeUrlPath) to re-import the current page to another page 20 void include (String relativeUrlPath) contains the config object of another file at the current position when a Servlet is initialized, the information used by the JSP Engine to pass information to it. This information includes the parameters used during Servlet initialization (consisting of attribute names and attribute values) and server-related information (passing a ServletContext object) serial number method description 1 ServletContext getServletContext () returns the ServletContext object containing server-related information 2 String getInitParameter (String name) returns the value of the initialization parameter 3 Enumeration getInitParameterNames () return the enumeration built-in object generation time of all parameters required for Servlet initialization. edit a JSP page corresponding to a Servlet class. Each Servlet class has three methods:
Init method: Initialize the JSP/Servlet method.
Destroy method: destroy JSP/Servlet method.
Service method: the method used to respond to user requests.
The request object and response object are the form parameters of the service method, application object, page Object, out object, pageContext object, and session object are all instances generated in the service method. These contents are described in detail on the struts self-media website.

Related Article

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.