Obtaining HTTPSession Object in Applet to Servlet Comm - JSDK 2.1
Joined: Feb 02, 2001
I have an applet as part of my website that uses applet to servlet communications. Before launching the applet the user logs into the site and an HTTP session is created. Data is stored in the session object that I want to pass to my applet. Specifically, user information. In JSDK 2.1, I cannot get the session from within my servlet method(s) using the deprecated getSession(sessionid) method. Is there any way to pass the session to my applet when it is launched? I don't want the users to have to log in twice, nor do I want to pass the userid and password in the html page that launches the applet, AND I want the last access time of the session updated whenever an applet to servlet communication occurs to prevent timeout. (my user sessions are timing out after extended use of the applet). Any thoughts would be appreciated.
Joined: Feb 11, 2004
did you got the solution ??? I�m looking for the same answer...
Sessions are server side objects. The client never has to know about them. The applet uses java.net.URL or java.net.URLConnection to send a request to the servlet and the session tracking is taken care of under the covers, usually as a cookie passed back and forth. In your servlet do a HttpServletRequest.getSession(true) call (the true parameter tells it to create a session if one doesn't already exist) and on your 2nd (and later) request you get the original session instance back. Changing the session timeout is a servlet container specific task. Consult your servlet container documentation if it causes a problem.