Well the issue is 

request.getSession(true)

Try something like 

MyObject myObj = new MyObject();
myObj.setAbc("Abc");
myObj,setDef("Def");
HttpSession session = request.getSession(false);

If ( session == null ) {
        session = request.getSession(true);
}

session.setAttribute(MySessionName, myObj);




HttpSession session = request.getSession(false);

If ( session != null ) {
        MyObject myObj =
(MyObject)request.getSession(true).getAttribute(MySessionName);
}


Because HttpSession session = request.getSession(true); will always create a
new session 

Regards
Guru 
-----Original Message-----
From: angelina zh [mailto:[EMAIL PROTECTED] 
Sent: 27 June 2005 17:18
To: Tomcat Users List
Subject: Re: http session lost between struts action


David,
 
Thanks a lot for your help.
 
My browser accepts cookies. Actually I inspected the cookies as well as the
session object when I was debugging. The cookies is a valid array with valid
sessionId inside and the method isRequestedSessionIdFromCookie() returns
true as long as the http session object is valid. But when the session got
lost, the cookies became to null and the method
isRequestedSessionIdFromCookie() returns false.
 
The links are the paths defined in the struct-config.xml file. The
jsessionid is still valid when the session get lost.
 
Here is how the code looks like in the LogInAction:
MyObject myObj = new MyObject();
myObj.setAbc("Abc");
myObj,setDef("Def");
HttpSession session = request.getSession(true);
session.setAttribute(MySessionName, myObj);
 
Here is how the code looks like in the following actions:
MyObject myObj =
(MyObject)request.getSession(true).getAttribute(MySessionName);
 
I have a FrontController servlet class to hand request and response. When a
link on the welcome page got clicked, I noticed that in the FrontController
servlet class, the session in the request became to null via eclipse's
debugging tool. (Before this point, the session is all valid.) Then in the
following action class, a new standard session got created. So my personal
session information totally lost.
 
Anything else I shall try?
 
Thanks so much!
 
Angelina

David Smith <[EMAIL PROTECTED]> wrote:
Check these:

1. Your browser is accepting cookies
2. Your links are being generated by taglibs that insure the jsessionid 
is attached if needed. I say if needed because if tomcat is getting a 
valid session cookie from your browser, the jsessionid won't be added to 
the link.

They don't both have to be done, but chances of eliminating errors are 
best if they are. Beyond that, I would have to suspect the way you are 
trying to access the session attributes either in setting them or in 
retrieving them. Could you post code snippets that show how you are 
setting and retrieving attributes?

--David



                
---------------------------------
Yahoo! Sports
 Rekindle the Rivalries. Sign up for Fantasy Football

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to