This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes Using sessions for authentication Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Using sessions for authentication" Watch "Using sessions for authentication" New topic
Author

Using sessions for authentication

Jahar Heard
Greenhorn

Joined: Jan 09, 2010
Posts: 20
I want to ask you something, how to use this session, when I log in , and then refresh the page it's back to the login form, I thing I'm doing something wrong.



Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41150
    
  45
What is the relationship between the session and whether or not the login page is shown? The code excerpt you posted doesn't show that.


Ping & DNS - my free Android networking tools app
Jahar Heard
Greenhorn

Joined: Jan 09, 2010
Posts: 20


Here is my login form.

The code is "working".But when I log in, and when it display my name, when I refresh the page, login form appear, and the name disappear.I think my problem is whit the session .

Any Ideas ?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41150
    
  45
There should be some logic in the doGet method that checks whether a session exists, and -if there is one- does something other than display the login form - maybe redirect to the main page.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60804
    
  65

Rather than checking for a session, check for the existence of something in the session. Much less fragile.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Using sessions for authentication
 
Similar Threads
help: getParameter returning null!
null exception when using session
syntax and error in ncf log
Constructor Problem
delete session with button