Request and Response objects

Source: Internet
Author: User

When I first approached the request and response object, we wrote a servlet class when we listened to Mr. Wang Yong's servlet. After we send a URL request on the browser, the Servlet class is called to handle the request, and the Servlet class is implemented by the overridden service () method, and we know that the request and response objects are the service () The parameters of the method are passed in.


1. Overall impression          

2.Request Objects


the main responsibility of the request object is to obtain the information encapsulated in the HTTP request, obtain the URL and form parameters, and a function to request and forward the page, when forwarding between two different servlets, You can use the request object as a pass between the two servlet data. When we were learning about. NET MVC, we learned that it was tempdata to pass data between different controllers, and the request object played the same role in MVC in Java. Its main methods as domain objects are:

①setattribute (Key,value)
②getattribute (Key)

③removeattribute (Key)
④getattributenames ()


3.Response objects


He can understand an "empty box" prepared for the server, we can put the contents into the box, the server will encapsulate the content as an HTTP response, sent to the client, and then the client to do the appropriate processing.

Summing down, I understand the request and the main function of the response object as shown, of course, this is only in the theoretical understanding, the specific application should be implemented in practice, the theory of graduation from the practice is meaningless, but the idea of clearing the way to better know our practice. The code is not shown here.






Request and Response objects

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.