views:

103

answers:

2

Hi guys,

I'll try as best as possible to explain what I'm doing in order to get best possible advice/solution. This is all done in java.

My client has a SWING based desktop application that will load using WebStart. I was assigned to create a Session Manager for user account information.

My friend suggested to rather use Http Session Management, so I've decided to try it out. I've written a servlet (let's call this SessionServlet) that does create, remove, and reassign sessions based on user profile. In tomcat 7, The sessions are not stored. I suspect that when the servlet is initialized, the session is blanked out. I only get, org.apache.catalina.ASYNC_SUPPORTED in Session.

My question(s) is/are:

  • How do I allow Tomcat 7 to do Session Management?
  • How can I do Session Management in Spring 3? I have most services running on Spring and I think it'll be wise enough for me to do Session Management on Spring.
  • What other means to do Session Management in java, is there a design pattern for Session Management? (just curious).

Thanks a million!

+1  A: 

I may be misunderstanding what you are trying to do with the session, but sessions (in terms of servlets) exist only while the user is accessing the site. So the user gets the first page and a session is set up, and is available to each page the user accesses. When the user leaves the site the session disappears. Is this the behaviour you are looking for or are you looking for something that will persist between visits to the site?

Jaydee
Something that will persist "forever". i.e. the session can exist forever until sometime it is asked to be destroyed.
The Elite Gentleman
I think you may be better off looking at cookies, which can persist for an extended period of time. NB I know very little about Spring.
Jaydee
I gave you a +1 for your effort.
The Elite Gentleman
+1  A: 

I've figured this out, so I'll share my input.

When doing Http Session Management (especially with Servlets), one has to make sure that the client-side session management also exists.

What happens is that when a session is created, the servlet returns a cookie with JSESSIONID value of the Session created by the servlet container. Make sure that the client side is able to store the session and use it everytime you need to access your session data from the server.

I wasn't storing the cookie from my side, so it seemed like the session were never created.

Hope this helps someone else.

The Elite Gentleman
That's correct. Too bad I missed the question. This is after all Servlet API related, so a `servlet` tag would be in place as well.
BalusC
Thanks BalusC, updated.
The Elite Gentleman