| Author |
Setting a session attribute in a servlet
|
Robert Stone
Greenhorn
Joined: Jan 06, 2011
Posts: 25
|
|
Hi I am having trouble setting a session attribute in a servlet and retreiving it in the jsp the servlet forwards to.
Below is the code from the servlet and the jsp. For some reason even thought I set the session attribute in the servlet when it forwards to the jsp the attribute is null.
//Servlet code here
//JSP code here
Any help will be greatly appreciated.
Thanks
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56179
|
|
Are you sure that the variable isn't null to being with?
P.S. And why the session? Placing the scoped variable on the request is sufficient for a forward operation.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Robert Stone
Greenhorn
Joined: Jan 06, 2011
Posts: 25
|
|
Are you sure that the variable isn't null to being with?
Yes I am sure it isn't null I ran it under eclipse and in the debugger I can see the object is populated before I put it into the attribute.
P.S. And why the session? Placing the scoped variable on the request is sufficient for a forward operation.
because it is a object that contains data that I want to access on a couple of pages.
|
 |
William Brogden
Author and all-around good cowpoke
Rancher
Joined: Mar 22, 2000
Posts: 12267
|
|
I wonder if you are even seeing the same session in the jsp - you seem to be forwarding to a different web app address so you will get a different session.
Bill
|
Java Resources at www.wbrogden.com
|
 |
 |
|
|
subject: Setting a session attribute in a servlet
|
|
|