my dog learned polymorphism*
The moose likes JSP and the fly likes Problem retrieving session value in jsp pagess Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » JSP
Bookmark "Problem retrieving session value in jsp pagess" Watch "Problem retrieving session value in jsp pagess" New topic
Author

Problem retrieving session value in jsp pagess

Fergus Red
Ranch Hand

Joined: Apr 25, 2002
Posts: 42
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

Joined: Sep 13, 2002
Posts: 331
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:


Blake Minghelli<br />SCWCD<br /> <br />"I'd put a quote here but I'm a non-conformist"
Fergus Red
Ranch Hand

Joined: Apr 25, 2002
Posts: 42
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.
 
GeeCON Prague 2014
 
subject: Problem retrieving session value in jsp pagess