File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes Sessions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Sessions" Watch "Sessions" New topic


Tom Joiner
Ranch Hand

Joined: Sep 19, 2006
Posts: 47
I am trying to use sessions to keep track of when a user is logged in to the website. It is only working on pages which are redirected from the one where the session is set- it does not work if the user links to a new page.

So my first page has the following code (which has been gotten from the database successfully). It redirects to another page

This new page works, in that it can extract the friendlyName and accountID, like this

However, this same code on any other page, does not work. If you press a link to go to another page, it does not see the friendlyname.

Any ideas?
[ March 05, 2007: Message edited by: Tom Joiner ]

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63841

Before anything else, why are't you just using the session builtin variable?

[Asking smart questions] [About Bear] [Books by Bear]
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
You are sending a redirect which asks the client(browser), to make initiate a new request to the associated URL.

As Bear suggested, you do should just be using the session built in variable. No need for a redirect. As long as they are bot part of the same session it should see the attributes set by the first servlet.

So much trouble in the world -- Bob Marley
I agree. Here's the link:
subject: Sessions
It's not a secret anymore!