aspose file tools*
The moose likes JSP and the fly likes If session is inactive then go to Login page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "If session is inactive then go to Login page" Watch "If session is inactive then go to Login page" New topic
Author

If session is inactive then go to Login page

dallr
Greenhorn

Joined: Nov 03, 2006
Posts: 2
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

Joined: Jan 10, 2002
Posts: 61761
    
  67

"dallr", please check your private messages for an important administrative matter.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61761
    
  67

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

Joined: Nov 03, 2006
Posts: 2
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

Joined: Jan 10, 2002
Posts: 61761
    
  67

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

Joined: Jan 10, 2002
Posts: 61761
    
  67

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: If session is inactive then go to Login page