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

session invalidate

Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Hi All,

i configure session timeout in my web.xml....

when the session time is complete,it is going to login page!!!.

i can not understand why it is?(by default going to loginpage(index.jsp)).....


but i want to show another jsp page after timeout...

please can anyone explain me..

thanks & regards,
seetharaman
Ashok Kumar Babu
Ranch Hand

Joined: Jul 25, 2006
Posts: 129
Hi,

In the sessionDestroyed method of SessionListener, forward to the signup page(whatever you want) using the Servlet Context's request dispatcher.


Ashok<br /> <br />SCJP 91%<br />SCWCD 88%
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Hi Ashok,
Thanks for your earnest reply...

well,..but my sessionDestroyed() method is in java class..

here how can i get request object so that,i can forward to my jsp page..

please explain me..

thanks & regards,
seetharaman
sudhir nim
Ranch Hand

Joined: Aug 29, 2007
Posts: 212

You can write a filter, which forwards to login page, if theres no session.


[Servlet tutorial] [Servlet 3.0 Cook Book]
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Hi All,

can anyone tell how to use RequestDispatched or anyother mechanism to forward to my jsp page...
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

"sudhir",
Please check your private messages.
-Ben


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12836
    
    5

here how can i get request object so that,i can forward to my jsp page..


You can't - there will never be a request when a session times out and is invalidated by the servlet container because initial processing of a request resets the timer for the matching session.

Bill
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Thanks William,

i want to show my jsp page..after session timeout in DD.for that wat can i do?..

i am waiting for your earnest reply..

thanks & regards,
seetharaman
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12836
    
    5
Think about this:

How will you identify a request as belonging to a recent user whose session timed out versus a request from a brand new user?

There is no way you can do this using ONLY the session mechanism.

I suggest you could use c ookies just like commercial sites do. Amazon recognizes me because my browser has (one or more) long-lived c ookie specific to the Amazon URL.

See the JavaDocs for java.servlet.http.C ookie for an introduction on how to create your own c ookies. Search for RFC 2965 for the complete rules on c ookies.

Bill
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Thanks william ;)
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: session invalidate