Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Session varibles not initialized .  RSS feed

 
Jesu Mani
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers,

I am trying with some simple servlet programs . I am printing the session object within the doget()method. And also tried to print the session object within the if {} block. Here this session value prints null.Is that the reason that the session is not initialized. i have placed this snippet in doget().

I expect someone to put a light on this ?

// Save and get a session-scoped value
HttpSession session = req.getSession(false);
if (session != null) {
session.setAttribute("session-param", "session-value");
value = session.getAttribute("session-param");
}
Thanks.
 
Jesus Angeles
Ranch Hand
Posts: 2070
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you created a session somewhere in your application already?

The code



will create a session if there isnt one yet.
[ February 06, 2008: Message edited by: Jesus Angeles ]
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!