IE Disable cookie mode:
Example one:
Demo.do Related Codes
public void doget (HttpServletRequest request, httpservletresponse response)
Throws Servletexception, IOException {
HttpSession session=request.getsession ();
String Jsessionid=session.getid ();
Cookie Sessioncookie=new Cookie ("Jsessionid", Jsessionid);
Session.setattribute ("name", "zzz");
String Url=response.encoderedirecturl ("./demo2.do");
Response.sendredirect (URL);
}
Demo2.do Related Codes
public void doget (HttpServletRequest request, httpservletresponse response)
Throws Servletexception, IOException {
HttpSession session = Request.getsession ();
Gets the ID of the session
String jsessionid = Session.getid ();
System.out.println (Session.getattribute ("name"));
}
Enter Address Http://127.0.0.1:8080/cookie/demo.do
Results
Address bar Results:
http://127.0.0.1:8080/cookie/demo2.do;jsessionid=D2B0058380743E3731D50C49E6355144
HttpWatch results:
Console has output as zzz
Example two:
Demo.do Code
Response.setcontenttype ("Text/html;charset=utf-8");
PrintWriter out = Response.getwriter ();
Out.println ("Out.println ("<body>");
String Url=response.encodeurl ("./demo2.do");
Out.println ("<a href= './demo2.do ' > Add to Cart </a>");
Out.println ("<body>");
Out.println ("
Demo1.do related invariant
The result is similar to example one
Description
(a), and then disable the cookie should be used IP address access Http://172.16.237.247:8080/web_11/goods.do?oper=detailCart
(ii), ¨ shows the problem caused by servlet sharing data after disabling cookies. ¨ solution: URL rewrite response. Encoderedirecturl (java.lang.String URL)
Used to override the URL address after the Sendredirect method.
Response. Encodeurl (java.lang.String URL)
Used to override the URL address of the form action and hyperlink
¨ Add: Session expiration Web. xml file configuration session expiration time
Javaweb Learning Record (15)--processing after a browser cookie is disabled