Action Access Servlet's API

Source: Internet
Author: User

Action accesses the api_ of the servlet, with the following main access:

1.> getting the Request object

2.> GET Request Parameters

3.> Gets the response object that can be used to pass cookies

3.> gets the scope object, Request,session,application, and sets the shared data,

Access Method One:    

By implementing the Setter method in the perceptual interface, the request parameter in its setter method is passed to this class:

That is, a member variable is defined in this class to receive the request from the setter method.

    

If you also need to get objects such as response,session,application, then you can only implement Servletresponseaware at the same time,

Applicationaware,sessionaware interface, and implement the setter method in it:

    

Access Mode II: Servletactioncontext Tool class through struts

      The corresponding request and response objects are obtained through the static methods in this class.

Method 3: Pass the Actioncontext tool class

    The class is the parent class of Servletacitoncontext, which represents the context object of the action, which indicates that the action exists in the environment

The class object is created through the GetContext () method in the class, and the object is obtained by calling the class method, such as using the GetParameters () method, which returns

A parameter's property name and a map of an array of property values,. When you need to set the request parameter, you add a key-value pair to the resulting map (that is, using the Map.put (Key,value) method;),

To complete the encapsulation settings for the shared request data.

Similarly, for sessions and application, first using Getseesion (), and getapplication (), this method also returns a map collection, as well as the need to set shared parameters,

By adding a key-value pair to the resulting map (that is, using the Map.put (Key,value) method), the encapsulated settings for the shared data can be completed.

    

Action Access Servlet's API

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.