wood burning stoves 2.0*
The moose likes Applets and the fly likes Obtaining HTTPSession Object in Applet to Servlet Comm - JSDK 2.1 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Obtaining HTTPSession Object in Applet to Servlet Comm - JSDK 2.1" Watch "Obtaining HTTPSession Object in Applet to Servlet Comm - JSDK 2.1" New topic
Author

Obtaining HTTPSession Object in Applet to Servlet Comm - JSDK 2.1

Andy East
Greenhorn

Joined: Feb 02, 2001
Posts: 4
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.
Felipe Ga�cho
Greenhorn

Joined: Feb 11, 2004
Posts: 1
did you got the solution ???
I�m looking for the same answer...
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8836
    
    7

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.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Obtaining HTTPSession Object in Applet to Servlet Comm - JSDK 2.1
 
Similar Threads
getRequestDespatcher() to open in another frame??
Where to put applets........
Doubts about Servlets and JSP(Please explain all my doubts with examples clearly)
RequestDispatcher
JSDK...