sharing sessions between 2 different requests

A

Aryeh M. Friedman

I have a situation where a servlet is passed an different session then the one it should be using (the one it should be using is passed as a var "id")how do I make it so the session the servlet (or jsp) uses is the one in the var and not in the passed session ideally I want something like this:

<%
session=SessionUtil.findSession(id);
%>

where SessionUtil is either prexisting or something I make my self.

Just in case people want to know the background see the other thread on JNLP sessions (I made it so I can pass the orginal session ID now but have no idea how to rejoin the two sessions)
 
A

Arne Vajhøj

I have a situation where a servlet is passed an different session
then the one it should be using (the one it should be using is passed
as a var "id") how do I make it so the session the servlet (or jsp)
uses is the one in the var and not in the passed session ideally I
want something like this:

<% session=SessionUtil.findSession(id); %>

where SessionUtil is either prexisting or something I make my self.

Any solution to this will probably be a bit tricky, but here is
my suggestion:
- define a HTTP session listener
- let that maintain a data structure where all sessions are stored
- never store anything directly in session instead store everything
in a (Hash)Map stored in the session
- when the second session has to be made "ready" you copy the ref
to that (Hash)Map from the first session to the second second
(the first session is found via the data structure in first item)

Arne
 
R

Roedy Green

session=3DSessionUtil.findSession(id);

Can't you use a reference to the session itself?

Can you build a HashMap of id to session every time you see an ID,
perhaps a WeakHashMap.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,154
Members
46,702
Latest member
LukasConde

Latest Threads

Top