Detailed explanation of Java HttpServletRequest and httpservletresponse

Detailed explanation of Java HttpServletRequest and httpservletresponse

Recently, due to the re encapsulation of CAS related jar packages, I want to achieve 0 configuration as much as possible, and a lot of problems are caused in this process

Use HttpServletRequest. It is sorted as follows for future reference. (the form is copied from other places. The typesetting is a little broken. Let's have a look.)

There are many classes and interfaces related to requests and responses. The following table shows the main classes and interfaces related to requests and interfaces.

Main classes and interfaces related to requests and interfaces

Among the classes and interfaces given above, the most important are the HttpServletRequest and httpservletresponse interfaces, which will be described in detail below.

1.HttpServletRequest

The most common method of HttpServletRequest interface is to obtain the parameters in the request, which are generally the data in the client form. At the same time, the HttpServletRequest interface can obtain the name transmitted by the client, the host name and IP address of the server that generates and receives the request, and the communication protocol being used by the client. The following table shows the common methods of interface HttpServletRequest.

Note: the HttpServletRequest interface provides many methods.

Common methods of interface HttpServletRequest

2.HttpServletResponse

In a servlet, the httpservletresponse interface is used when the server responds to a request from the client. To set the type of response, you can use the setcontenttype () method. To send character data, you can use getwriter () to return an object. The following table shows the common methods of interface httpservletresponse.

Common methods of interface httpservletresponse

Thank you for reading, hope to help you, thank you for your support to this site!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>