Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Setting a session attribute in a servlet

 
Robert Stone
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65226
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Robert Stone
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 13074
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic