This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes Struts and the fly likes Session Management Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Session Management" Watch "Session Management" New topic

Session Management

Frank Truong
Ranch Hand

Joined: Nov 19, 2002
Posts: 39

I have a question about session object utilized in Struts.

In my SignOnAction, I keep a copy of java.sql.Connection object in the session, so I can re-use it later. This works well locally (Tomcat inside netbeans). However, it always returns null on this Connection object when I run the project outside of IDE(external Tomcat). I am sure I am using the same session object(session.isNew() returns false). I could even 'see' this Connection object in my jsp page, but when entering subsequent action, the same session(I think because session.isNew() returns false) no longer carries that Connection object.

Did my jsp just create another session for me???

What would be your suggestion where I should look into?

Thank you.
Nishan Patel
Ranch Hand

Joined: Sep 07, 2008
Posts: 689


Session will not depend on your IDE.. and you jst will not create automatically session for you...

Just check have you use same name variable as your session variable name some where else or debug your application on that request.....

Thanks, Nishan Patel
SCJP 1.5, SCWCD 1.5, OCPJWSD Java Developer,My Blog
Frank Truong
Ranch Hand

Joined: Nov 19, 2002
Posts: 39

I have realized that my session has lost between actions.

I have tested my program on multiple computers; the program works for all machines except on one computer in which I always got a new session in subsequent action even though I tried not to create new one by using request.getSession(false) method in this action. Apparently, a new session has already been created before this method call. Right before the execution gets to my action, I double-checked my session id (in my jsp) and my session was still there. The only place the execution has gone through before executing my action is the actionform which should not have anything to do with session creation, I believe.

This issue is occurring on ONLY ONE machine. I turned to cookies settings on the browser since some blogs have offered that if browser disables cookies acceptance, the session will be lost between actions. I made this browser more generous on cookies acceptance but problem still persisted.

I am stuck.

Dpk arora

Joined: Feb 17, 2010
Posts: 4
Hi Frank,
Even I am facing the same issue. did you gt the solution of this problem?

Frank Truong
Ranch Hand

Joined: Nov 19, 2002
Posts: 39
Hmmmh, It has been awhile. I didn't document how I could get by this issue!

I have made quite a number of changes in order to get by this issue. Among those changes, in javascript code, was to have replaced XMLHttpRequest with ActiveXObject('Microsoft.XMLHTTP') - my app supports only IE!

Not too helpful, is it?

Good luck.
Have you checked out Aspose?
subject: Session Management
It's not a secret anymore!