This week's book giveaway is in the Game Development forum.
We're giving away four copies of Badass: Making Users Awesome and have Kathy Sierra on-line!
See this thread for details.
The moose likes JSP and the fly likes Issue with getSession().setAttribute() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Badass: Making Users Awesome this week in the Game Development forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Issue with getSession().setAttribute()" Watch "Issue with getSession().setAttribute()" New topic
Author

Issue with getSession().setAttribute()

Tiago Fernandez
Ranch Hand

Joined: May 16, 2003
Posts: 167
Hi,
What's wrong with the followin' code?

1) Settin' the session attribute:
request.getSession().setAttribute("logged", user);

2) Checkin' if the user is logged:
String status = request.getSession().getAttribute("logged") == null ? "deny" : "allow";
if (status.equals("deny"))
// do something here...

The problem is that getAttribute() always returns null...
Tks,


Tiago Fernandez
http://www.tiago182.spyw.com/
ib idris
Greenhorn

Joined: Aug 02, 2003
Posts: 29
In JSP you don't have to use request.getSession() but session. If you always get attribute null, maybe user is always null or the session is invalidated at some point. You can check with session.isNew().

http://galileo.spaceports.com/~ibidris/
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Issue with getSession().setAttribute()