#1
  1. No Profile Picture
    Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    May 2003
    Location
    Brisbane, Australia
    Posts
    1,442
    Rep Power
    28

    Storing a request for later use


    My site is password protected and stores information about the user in the session. What I'd like to do is set my site up so that if the users session times out and then they click a link they will be redirected to the login page. If the login is successful they should then be redirected to the page they were attempting to go to.

    I have got this working up to a point by storing the URI and request Query they were attempting to access when I detected the session time out.

    What I'd like to do is store a copy of the actual request so that if I detected a time out while they were submitting a form I can use the stored copy of the request for processing once I have authenticated the user.

    I've tried storing the request as a session attribute but it gives wierd results.
    If (session.getAttribute("OldRequest") == null)
    returns false but
    ((HttpServletRequest)session.getAttribute("OldRequest")).getRequestURI() results in a null pointer error.

    I suspect that the request is being automatically invalidated when I shunt the user off to another page but I'm not sure.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2003
    Location
    No es importante
    Posts
    2,065
    Rep Power
    14
    You could store the last requested page in a database and reference that if necessary.
  4. #3
  5. No Profile Picture
    Clueless llama
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Feb 2001
    Location
    Lincoln, NE. USA
    Posts
    2,353
    Rep Power
    117
    One method would be to use a controller servlet to process incoming requests. The advantage of this is that you can have it process an information-bean that can be saved to a session before checking if the user is logged in. If the user isn't logged in, they can be forwarded to the login page and then redirected back to the requested source. Their originally submitted info will be in the session at that point as the bean. All jsp's will use an information bean instead of getting any info from the request. This is all possible with Struts. You might want to check it out.

IMN logo majestic logo threadwatch logo seochat tools logo