Servlet—07—Cookie; Seesion;


 

A, Cookie

Before learning Cookie, we look first to write a servlet class, concrete steps to override the parent class service approach:

. 1  -Service ()
 2  {
 . 3      // Setup Request encoding format
 4      // set the response encoding format
 5      // acquiring request information
 6           // Get cookie data
 7      // processing request information
 8      // response processing result
 9          // create cookie data
 10      // response cookie data  
 11         // 1. direct response to
 12         @ 2 forwards the request to another servlet class
 13         // 3. the redirection     
14   }              

You may full of questions about the cookie, do not worry, we have now come to understand Cookie!

1. Problem:
  different data requests use the same request, but as long as the end of the request, the data is destroyed, other requests will need to resend a common data; so, each time re-fill data, very troublesome! There is no good way, often need to fill in the data, stored it?
2. Resolution:
  Yes, that is the use of cookie technology!
3. Features:
  (1) command the server, the browser stores the data;
  (2) data that needs to be stored is declared on the server side, as to tell the browser in response;
  (3) is not provided on the valid browser is closed fail;
  (4) inappropriate storage of large amounts of data;
4. action:
  the problem of data sharing between different requests of the problem.

 

 

Two, Cookie code implementation 

 

Guess you like

Origin www.cnblogs.com/EricShen/p/11482111.html