The built-in JSP object ---request

JSP built-in objects
Some objects can script section of the JSP page without using a statement, this is JSP's built-in objects.
JSP's built-in objects: resquest , response, session, application , out
Response and request objects are the two most important JSP's built-in object, the two object provides control of the browser and server communication method.
----Word Wide Web protocol, 1.HTTP protocol
Known as "the request and response" protocol
The 2.request object
HTTP communication protocol is between a client and a server a submission (request) information and response information (request/respone) communication protocol.
In JSP, built-in request object encapsulates the information submitted by users, then call the corresponding method of the object to access the information package, namely the use of the target users can access the information submitted.
The main difference between 2.1Get method and post method is:
Use the get method to submit information will be displayed in the browser's address bar in the submission process, information and the post method submitted will not be displayed in the address bar.
2.2 access to customer information submitted:
The most commonly used method for the request object to obtain customer information submitted is getParameter (String s). S the name attribute of the tag.
2.3 Chinese characters information processing:
When getting the client submits Chinese characters characters with request objects, will appear garbled problem, so the Chinese characters character information must be special treatment. First of all, will get
The string is encoded using ISO-8859-1, and the code is stored in a byte array, and then the array into a string object.
String str=request.getParameter("girl");
byte b[]=str.getBytes("ISO-8859-1");
str=new String(b);
The built-in object request object 2.4JSP engine to obtain customer information submitted
2.4.1. getProtocol() To obtain client communication protocol by which information to the server, such as http/1.1 etc.
2.4.2. getServletPath() Obtain customer requested JSP page file directory.
2.4.3. getContentLength() To obtain the entire information submitted by customers length.
2.4.4. getMethod() Obtaining client information, such as: post or get.
2.4.5. getHeader(String s) The value specified by s head name gets the HTTP header file;, generally s parameters seem to be the top: accept, referer,
accept-language , content-type , accept-encoding , user-agent, host, content-length, connection, Cookie,
For example, s value user-agent will get the customer's browser version number and other information.
2.4.6. getHeaderNames() An enumeration name for head
2.4.7. getHeaders(String s) All the value specified header name gets in the header file; an enumeration
2.4.8. getRemoteAddr() For client IP address.
2.4.9. getRemoteHost() Gets the name of the client machine (if not available, we obtain IP address).
2.4.10. getServerName() Gets the name of the server.
2.4.11. getServerPort() Get the server port number.
2.4.12. getParameterNames() Gets the name parameter information body part client submits an enumeration of value.

Posted by Rupert at December 19, 2013 - 9:19 PM