struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <>
Subject RE: Session without cookies
Date Mon, 24 Apr 2006 09:26:24 GMT
I think some where(may be in the action class association with the action / you are
creating new session each time for each request. Most possible mistake could be using


See below documentation from Servlet Specifications
public HttpSession getSession()
	Returns the current session associated with this request, or if the request does not have
a session, creates one.
	Returns: the HttpSession associated with this request
See Also: getSession(boolean)

public HttpSession getSession(boolean create)
	Returns the current HttpSession associated with this request or, if if there is no current
session and create is true, returns a new session. If create is false and 	the request has
no valid HttpSession, this method returns null.

To make sure the session is properly maintained, you must call this method before the response
is committed. If the container is using cookies to maintain session integrity and is asked
to create a new session when the response is committed, an IllegalStateException is thrown.

<code>true</code> - to create a new session for this request if necessary; false
to return null if there’s no current session Returns: the HttpSession associated with this
request or null if create is false and the request has no valid session
See Also: getSession() 

-----Original Message-----
From: Chan Michael [] 
Sent: Monday, April 24, 2006 2:48 PM
Subject: Session without cookies

Hi All,

I have been searching for hours and still cannot find any useful info. Hope you can help.

I am building a Struts app. (Struts 1.2.4 + Tomcat 5.5
+ Apache 2.0.55 + Spring 1.2.6) and want to use
session without
enabling cookies. I use <html:link> to create links so ;jsessionid is appended to the
end. Fine. The problem I have is every time I access a page, a new session id is created so
essentially everything stored in session is lost. Here is some output from my test action,
HttpSession session = request.getSession(); System.out.println("Is session new? " + session.isNew());
System.out.println("Session id: " + session.getId());

First access
Is session new? true
Session id: B9F9E135DCBAC90AB2B5AEBCE901FAA5

Second access
Is sesssion new? false
Session id: 8CCE7A388E76C0F56016E8F41E29E0E5

The session is not new but the id is different...I already set in Tomcat server.xml

<Context path="/myApp" cookies="false"...>

What am I missing??

Thanks in advance.


 YM - 離線訊息

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message