wood burning stoves 2.0*
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
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()
 
Similar Threads
How to implement authentication for each jsp page
I can't get my query cache to work...
Session
Struts, tiles and getRequestURL()?
Correct way to check Session timeout?