HTTP protocol Detailed
Requsert Headers The request information sent by the browser to the server
Get/myweb/persons.html http/1.1 (required)
host:localhost:8080
Connection:keep-alive
Accept supported formats:
accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
User-agent: Browser-compatible version
Accept-encoding: Supported compression encodings
ACCEPT-LANGUAGE:ZH-CN Simplified Chinese
Response headers server responds to browser information
http/1.1 OK
OK
404 on behalf of not found
403 Client not authorized
302 redirect Movedtemporarily temporarily moved the address of the Localtion page webpage;
Internal Server error Server Internal error
The HTTP protocol status code indicates different problems respectively;
Browser requests the difference between get and post
1.GET put the information directly behind the GET and post put the information in the newspaper style inside
2.GET file server is not modified when the cache is read directly. The post is a new request every time.
Relative path and absolute path
"." Represents the current folder
".." Represents the previous level of the directory
"/" means the root directory
Relative path refers to the path relative to the referenced file;
Absolute path refers to the path relative to the root directory;
Class objects and methods in Java that process server requests.
HttpServletResponse
Sendredirect () redirect redirects to a new address
setContentType Text/html;charset=utf-8
Setcharacterencoding Utf-8
Getoutputstream the stream of the reported style that gets the response
Method of HttpServletRequest.
QueryString get? What's behind I=5&j=8 localhost:8080/myweb/chengyi?i=5&j=8
Req.getcontextpath () Contextpath/myweb
REQ.GETREMOTEADDR () remoteaddr IP address
Req.getrequesturi () requesturi/myweb/test root directory starting with path without parameters
Req.getinputstream () Gets the flow of the request body
Getservletcontext (). Getrealpath () Gets the path under the server folder. Not the source code path
Javaweb part3----An explanation of the HTTP protocol, and the classes and methods of request response in Java