Sometimes when the session is being manipulated, the system throws the following exception
Java.lang.IllegalStateException:Cannot create a session after the response has been committed
This type of problem occurs because we create a session after the response output response.
(because the server already sent the data to the client, that is, the session ID could not be sent)
Solution:
1. Create a statement to access the session "Request.getsession ()" Before the response output data is good.
For example, change to the following wording OK:
Servletoutputstream out = Response.getoutputstream ();
It's best to be next to Response.getoutputstream ()
HttpSession seesion = Request.getsession ();
Seesion.setattribute ("xxx", Rand);
Output data
Out.print ("Out.close ();
2. If you use the STRUTS2, you can add a default interceptor to the Struts.xml:
<interceptor-ref name= "CreateSession"/>
<interceptor-ref name= "Defaultstack"/>