In the b/s architecture, there are request browser requests and response server feedback. The underlying layer is the tcp/ip protocol, and the application layer is the http protocol. In the tomcat server, version 6 uses the http1.1 version protocol. The server issues a request request, and it is possible to load get and post requests (doget requests) in the request. You can use getparmeter to parse in the URL. Because tomcat treats each web request as an object, it is encapsulated with object-oriented (HttpServletRequest) and has dog and dopost for corresponding parsing. The main APIs are as follows:
Core API:
Request line:
request.getMethod(); request method
request.getRequetURI() / request.getRequetURL() Request resource
request.getProtocol() requests http protocol version
Request header:
request.getHeader("name") Get request value based on request header
request.getHeaderNames() Gets all request header names
Entity content:
request.getInputStream() gets the entity content data
There is a coding problem involved in the request request. Setenconding is OK, bytecode casting is OK, and XML configuration is OK.
For the feedback from httpservletresponse server, it also involves encoding issues and can be declared in the response header. Others can also be cast bytecode (like socket programming, base64 encryption and other memory). Various feedback codes of the browser, such as 404,500, have also been roughly learned.
Common response headers
Location: //www.VeVB.COM - represents the redirected address, which is used together with the status code of 302. Server:apache tomcat ---Indicates the type of server Content-Encoding: gzip ---Indicates the data compression type sent by the server to the browser Content-Length: 80 ---Indicates the length of data sent by the server to the browser Content-Language: zh-cn ---Indicates the language supported by the server Content-Type: text/html; charset=GB2312 ---Indicates the data type and content encoding sent by the server to the browser Last-Modified: Tue, 11 Jul 2000 18:23:51 GMT ---Indicates the last modification time of the server resource Refresh: 1;url=//www.VeVB.COM ---Indicates the time of refreshing Content-Disposition: attachment; filename=aaa.zip -- means telling the browser to open the resource by downloading (used when downloading the file) Transfer-Encoding: chunkedSet-Cookie:SS=Q0=5Lb_nQ; path=/search -- means the cookie information sent by the server to the browser (used for session management) Expires: -1 -- means notifying the browser not to cache Cache-Control: no-cachePragma: no-cacheConnection: close/Keep-Alive -- means the connection status of the server and the browser. close: close the connection keep-alive: save the connection
The above brief discussion of request and response in servlet is all the content I share with you. I hope it can give you a reference and I hope you can support Wulin.com more.