aspose file tools*
The moose likes Servlets and the fly likes Life cycle fo session attributes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Life cycle fo session attributes" Watch "Life cycle fo session attributes" New topic
Author

Life cycle fo session attributes

sruthi reddy
Ranch Hand

Joined: Aug 03, 2008
Posts: 34
Hi
I am using session atttibutes to know whether a user is loged in or not.Basically what i am doing is i am authenticating user with database and if user's username and password are correct, then in the sevlet i am setting a string to yes value and checking that condition where ever required in the application.But in some pages of application, i have a link which will call my main page.If user is loged in then, my main page should have user details but its not happening. my session attributes are not available in main page. Can anyone suggest me what to do.
Thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60046
    
  65

What is happening?
[ August 08, 2008: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
sruthi reddy
Ranch Hand

Joined: Aug 03, 2008
Posts: 34
i am setting session attributes like this

request.getSession().setAttribute("usName", usrName);
request.getSession().setAttribute("isLoggedIn", testLogin);
response.sendRedirect("Online/CalenderDisplay.jsp");

and i am able to get back those values in CalenderDisplay.jsp (my main page) but when i am trying to get attributes from other pages, i am getting null value.
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6657
    
    5

Perhaps you are attempting to retrieve it with the wrong keys ? Why dont you try printing all the keys and values in the session attribute scope ? You can also register some listeners in case you want to be notified when a session object is added or removed or replaced. This way any change in these values will be visible to you via debug statements.


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12674
    
    5
I am trying to get attributes from other pages, i am getting null value.


Are all of these pages in the same web application? Show us the URLs by which these pages are reached.

Bill


Java Resources at www.wbrogden.com
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Life cycle fo session attributes
 
Similar Threads
Session problem
'no. of users online'
how i can redirect (without loosing session) to a full url from jsp page in struts.
simple logic to authenticate users
Disable browser back button and refresh in jsp page