If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Redirecting a session to another server

How does one redirect a session on one web server (computer A) to another
web server (computer B) and retain all of the session information, like a
Bean that has been instantiated (on computer A) and has session scope, etc.

Re: Redirecting a session to another server

In article <399a9797$1@news.devx.com>,
Carl Crosswhite <Carlxw@ix.netcom.com> wrote:
>
>How does one redirect a session on one web server (computer A) to another
>web server (computer B) and retain all of the session information, like a
>Bean that has been instantiated (on computer A) and has session scope, etc.

There's nothing in the JSP specification that allows for this,
unfortunately. However, there are a few ways you could go about it.

If both computers have access to some database, A could store all the
session information into a table before the redirect, and then a
servlet or JSP on B could retrieve the data and use it to rebuild the
session. You would also need to pass some sort of ID in the redirect,
so that B would know which data to retrieve.

Alternately, you might be able to pass all the session information
through the query string when you do the redirect. This would be
pretty easy to implement if everything in the session is simple data
like ints and strings. If you are storing a lot of objects in the
session, this gets messier.

Some application servers may provide functionality behind the base JSP
spec. I think ATG's "Session Federation" allows data to be shared
between applications running on different machines.

Re: Redirecting a session to another server

larnep@canetoad.canetoad.com (Larne Pekowsky) wrote:
>In article <399a9797$1@news.devx.com>,
>Carl Crosswhite <Carlxw@ix.netcom.com> wrote:
>>
>>How does one redirect a session on one web server (computer A) to another
>>web server (computer B) and retain all of the session information, like
a
>>Bean that has been instantiated (on computer A) and has session scope,
etc.
>
>There's nothing in the JSP specification that allows for this,
>unfortunately. However, there are a few ways you could go about it.
>
>If both computers have access to some database, A could store all the
>session information into a table before the redirect, and then a
>servlet or JSP on B could retrieve the data and use it to rebuild the
>session. You would also need to pass some sort of ID in the redirect,
>so that B would know which data to retrieve.
>
>Alternately, you might be able to pass all the session information
>through the query string when you do the redirect. This would be
>pretty easy to implement if everything in the session is simple data
>like ints and strings. If you are storing a lot of objects in the
>session, this gets messier.
>
>Some application servers may provide functionality behind the base JSP
>spec. I think ATG's "Session Federation" allows data to be shared
>between applications running on different machines.
>
> - Larne

Hmmm, that's clever. You would have to make sure that the session
gets to the second machine before the user does, but that shouldn't be
too hard to arrange. And you would still need some way to attach the
user to the session once they get to the second machine, but all you'd
need here is an ID.