• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem retrieving session value in jsp pagess

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic