I want to configure idle and maxtimeout url's where user is redirected on session timeouts. This page should show the user message that the session has timed out and then in few seconds redirect the user to the page which they were last accessing.
So basically I don't want user to directly go to the login page but first see the message that the session has timed out.
Basically, in order to show the user message that the session has timed out, you may use Agent Configuration Parameters: IdleTimeoutURL and MaxTimeoutURL. For detail, see the docops.
Next, regarding capturing the last accessed url, unfortunately I do not have such code that you are asking. But, please let me show just an idea - you could make use of the “Referer” HTTP header in the HTTP request to such URL as IdleTimeoutURL or MaxTimeoutURL.
I mean: if IdleTimeoutURL is targeted to a JSP (or something else) for example, then it might capture the header and pursue the redirection that you want.
IdleTimeoutURL = ”http://example.mycompany.com/sessionidletimeoutpage.jsp”
I hope this will help.