Re: Share a Session

From: William Brogden (wbrogden_at_bga.com)
Date: 12/08/04


Date: Wed, 08 Dec 2004 07:41:03 -0600

On 8 Dec 2004 10:02:13 +0100, Peter Kirk <peter> wrote:

> "William Brogden" <wbrogden@bga.com> skrev i en meddelelse
> news:opsinkid1lk0yerx@ruby...
>> On 7 Dec 2004 14:29:44 +0100, Peter Kirk <peter> wrote:
>> You could write the sessionID into the applet tag as a parameter.
>> Of course, both servlets would have to be in the same web application
>> for it to be meaningful.
>> Bill
>
> Hi, thanks for the answer. Both servlets are in the same web-application:
> both are confugured in the same web.xml.
>
> How exactly do I use the session id from the applet? Does the applet just
> send it in the POST request to the servlet: for exmple,
> sessionID="xxx123" ?
> (Is there a special name to use?)

I think you would have to emulate a cookie and use exactly the
same name that the servlet normally uses which is "JSESSIONID"
Look at java.net.URLConnection - the setRequestProperty method
will let you set a cookie header - I don't remember the exact
syntax - hunt for RFC2109. I think you end up with something like:

connection.setRequestProperty("Cookie","JSESSIONID=" + session );

>
> Then what does the servlet do with it to get hold of the actual session?
> Just call session = request.getSession()?

Right - it should be handled just like a request from a browser.

>
> Thanks,
> Peter
>

Bill



Relevant Pages

  • Re: TOMCAT PROBLEM: Establishing a session
    ... > I have a java applet running inside the html produced by the java ... > servlet, we have written a second servlet which implements a HashTable ... Do note that where sessions are maintained via a session cookie, ... You must also take care when trying to pass request parameters ...
    (comp.lang.java.programmer)
  • Re: TOMCAT PROBLEM: Establishing a session
    ... I am aware that the applet and the servlet will have different session ... You must also take care when trying to pass request parameters ...
    (comp.lang.java.programmer)
  • Re: Servlet, session, and applet
    ... > The controller servlet maintains a session, ... > One of the views includes an applet, which needs to call another servlet ... and JSP APIs. ...
    (comp.lang.java.help)
  • Servlet, session, and applet
    ... The controller servlet maintains a session, ... some user information. ... One of the views includes an applet, which needs to call another servlet to ...
    (comp.lang.java.help)
  • servlet/applet communication problem or Linux/Windows trouble ?
    ... frame contains a little form which has the servlet (running on my ... used to load a page with the applet. ... then the servlet listens on port 14444 ... until a connection request is received, and opens a clientSocket. ...
    (comp.lang.java.programmer)