Built-in objects for JSPs

Source: Internet
Author: User

Summary of built-in objects

A JSP built-in object is an object that is loaded by a JSP container and can be used directly in a JSP page without declaring it.

nine large built-in objects

1.request: A client request that contains all the request information sent from the browser to the server.

The request object is an instance of the HttpServletRequest interface implementation class. For example: request source, cookie and client request related information. can access data

Common usage: string getparameter (string name) to get a single value from a parameter

String[] Getparametervalue (String name) to get a set of parameter values based on the parameter name

void SetAttribute (String name, Object value) to store data

Object getattribute (String name) gets the stored data by name

2.response: Returns the response of the client.

The response object is an instance of the HttpServletResponse interface implementation class and is responsible for sending the response results to the browser side.

Common usage: void setContentType (String name) to set the type and character encoding of the corresponding content

The void senredirect (String URL) is redirected to the specified URL resource.

3.session: Session object that represents the session state of a session cycle.

The session object is an instance of the implementation class of the HttpSession interface. can access data

4.application: Applies the context object, acting on the entire application.

The Application object is instantiated at the start of the container and destroyed when the container is closed. can access data

5.out: output stream, output data to client.

6.page: Represents the current instance of the page.

7.pageContext: Used to store the current JSP page information. can access data

The configuration information object for the 8.config:jsp page.

9.exception: Exception object for handling error messages in JSP pages.

Note: The four scopes of JSP are pagecontext,request,session,application. If you refresh a page, its pagecontext is always 1, because it accesses the current JSP page, the session access scope is the current conversation, so when the page is refreshed, the count continues to increase, but when a new window opens, a new session is created, so the count starts from 1 The application access scope is the entire application, so the count continues to increase.

Built-in objects for JSPs

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.