Its giving you null pointer because you've created a request object with null reference. And you're using it to redirect to a page. That's why it is giving you NPE(Null Pointer Exception). Your request req object must be initialize first before using it.
You cannot do some thing like..
It should be
Joined: Jun 08, 2009
But how is it possible please give me a small example
Sorry, just saying that it's a requirement doesn't mean that it makes any sense at all. And in this case it doesn't.
When the client's session expires, the client hasn't connected to your site for the last 30 minutes (or whatever your timeout period is). So there isn't any request to be redirected, as has already been said at least twice.
And even if the client's browser is still running (which it might not be), the client isn't going to be happy if your application popped up over their Youtube viewing to inform them of the irrelevant fact that their session had expired. It wouldn't be a good idea to tell your clients that this is a stupid requirement (although it is) but you do have to explain to them that it can't be implemented and that it shouldn't be implemented.
hey there, you should probably revisit the design, you should not redirect to any page after the session has been destroyed. You could probably check in any action class if the request contains the credentials or your session object still has it and only then you redirect it to the proper page and not the other way.
However you can use the jsp <whatever you use>. Request can never be "null" - even if it is expired... but once again.. its time to revisit the design.
subject: How can I redirect from sessionDestroyed() of Session Listener