1.request objects are primarily used to process client requests
Common methods for Request objects
A. String Request.getparameter (string name) gets the value values of the component based on the component name value of the page form (note: If the requested component name does not exist, return NULL if the request component's value Value is null returns "" empty string)
Two. String request.getparametervalues (string name) gets a set of component value values with the same name (the content of the checkbox multi-select button is primarily obtained)
Three. Request.getrequestdispatcher (String path) returns an object and then invokes the. Forward (Request,response) with the object; for forwarding requests
Four. Request.setcharacterencoding (String CharSet) specifies the encoding of each request and is set before calling the Request.getparameter () method to solve the Chinese garbled problem
Five. Request.getcookie () Read all cookie content
2.response objects are primarily used for server-to-client response
Common methods for response objects
I. Response.sendredirect (String path) request to relocate to a new URL
Two. Response.addcookie (cookie cookie) to send cookies to the browser
--------------------------
3. Chinese garbled problem
I. Using the fourth method of request to set if Request.setcharacterencoding ("UTF-8") is encoded as utf-8 then the values of pageencoding and charset in the page directive will be consistent with Utf-8.
Two. String Name=request.getparameter ("username");
Name=new String (name.getbytes ("ios-5589-1"), "Utf-8"); The name string is parsed into a byte array with ios-5589-1 encoding, and the byte array is reconstructed with a new string by using the Utf-8 encoding with the new string () method.
Three. Add the Uriencoding attribute value in the Tomcat directory structure conf/server.xml file <connector> element to: Utf-8 (note: Use mode three is not recommended.) )
--------------------------
JSP built-in object request and response