Re: Share a Session

From: William Brogden (
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" <> 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 - 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