• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
Bartenders:
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

simple sessions help

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,

Im just trying to use sessions to store a username in one page, and read it in another, as follows.

But it keeps telling me that username is null (ie. it thinks the session attribute username doesnt exist).

I think i identified the problem. Each time i go to a new page and check for the username attribute in the session - a new session is created instead of looking in the existing one.

Do i need to set, import or initlalise something before i can use sessions.

Note im using Tomcat 5.5.9 bundled in Netbeans 5.0.

Please help, thanks




[ May 28, 2006: Message edited by: john latham ]
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't see anything wrong with the code you have provided. You have left out how you are grabbing the session from the request each time, which might pose a clue. I did basically the same thing you did and all was fine.

login.jsp


index.jsp
 
john latham
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My firewall was somehow blocking my sessions so i closed it and my session code started working.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic