How do I get that to work?
The problem is that I want the information that servlet number one stores to be available from servlet number two and vice versa. Just using getSession doesn't seem to be enough. Should I use the ServletContext in any way to make it work?
Thanks
Markus
-
One session - many servlets (3 messages)
- Posted by: Markus Kirsten
- Posted on: December 05 2001 09:36 EST
Threaded Messages (3)
- One session - many servlets by Andy Nguyen on December 05 2001 11:15 EST
- One session - many servlets by Darren Abbruzzese on December 07 2001 05:26 EST
- One session - many servlets by Race Condition on December 07 2001 08:22 EST
-
One session - many servlets[ Go to top ]
- Posted by: Andy Nguyen
- Posted on: December 05 2001 11:15 EST
- in response to Markus Kirsten
Storing information in the session should make it shareable to any other servlet/jsp in the same web application during the same session. To share the information to any servlet/jsp in the same web application regardless of a user's session, you can put it in the ServletContext. Just be aware of the threading issues.
Andy Nguyen
anguyen@itginc.com -
One session - many servlets[ Go to top ]
- Posted by: Darren Abbruzzese
- Posted on: December 07 2001 05:26 EST
- in response to Andy Nguyen
So long as either the user's browser supports cookies or you encode the session id into the URL then you shouldn't have any problems using state between servlets.
In servlet A:
request.getSession().setAttribute("Some Key", "Some Value");
In servlet B:
String value = (String) request.getSession().getAttribute("Some Key");
Obviously, the usual NullPointerExceptions should be allowed for etc. etc. but on the whole it is quite straight-forward.
-
One session - many servlets[ Go to top ]
- Posted by: Race Condition
- Posted on: December 07 2001 08:22 EST
- in response to Markus Kirsten
servlet work many wonder. power, robust, sped.
how to loop? switch?