• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

If session is inactive then go to Login page

 
dallr
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Morning all,
I don't want a user to type in a url and visit authorized webpages unless the session is activated.

What do i need to place on my jsp to check to see if the session if inactive and if so redirect the user to the login page.

Thanks in advance for your assistance.

dallr
[ October 23, 2008: Message edited by: dallr ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64620
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"dallr", please check your private messages for an important administrative matter.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64620
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by dallr:
What do i need to place on my jsp to check to see if the session if inactive and if so redirect the user to the login page.
Nothing. It's not the JSP's job to handle this.

Rather, use a servlet filter to check if the session credentials exist and forward to the login page or not. This centralizes the processing in one place, and keeps your JSPs clean and free of needless goop.
 
dallr
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the quick feedback, that makes more sense.

But how would i check to see if the session is active?

Dallr
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64620
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is imperative that you read my private message as previously instructed and take appropriate action as outlined within. Do this prior to your next post.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64620
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That greatly depends upon what "active session" means to your application. For most, it means that the user has logged in and that a token has been placed in the session identifying the user.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic