Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem retrieving session value in jsp pagess

 
Fergus Red
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am trying to rretrieve a session value from a jsp page and cannot seem to do so correctly.
What I am doinng is using a Model-View-Control process.
I Have a dispatcher servlet which controls where the user goes on the web site. I pass in servlets to call and a jsp view page as values to the dispatcher servlet.
When the user clicks on the url. It first of all calls the dispatcherservlet. Then it calls a createVisitId servlet and then redirects to the required jsp page.
In the createVisitId servlet a visitId is set in session.
When I redirect to the jsp page I retrieve my visitorId value from my session. This seems to work fine for the first jsp page I go to. However for all other jsp pages I then go to, I cannot seem to be able to access my visitorId from the session anymore.
Does anyone know where my problem lies, and if so - how to solve it?
 
Blake Minghelli
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This may be a stupid question, but without seeing your code...
Are you sure you are adding your object to the HttpSession and not the HttpServletRequest? Since your code only works for the first request, it sounds like maybe you are doing:

Instead of:
 
Fergus Red
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's funny Blake - but I found out afterwards that that is exactly what I was doing wrong. I have since fixed my problem.
Cheers for the help.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic