Results 1 to 4 of 4

Thread: Return to previous page from onSubmit

Hybrid View

  1. #1
    Join Date
    May 2008
    Posts
    10

    Default Return to previous page from onSubmit

    Hi.

    I'm trying to find a good way to return to the calling page after processing a form in a SimpleFormController. For example, I have an edit page called "edit.jsp", and I have an "edit" link on pages a.html, b.html, and x.html. Once the user clicks "Submit" from edit.jsp, I'd like to return the user to whatever page he clicked "edit" from. That is, either a.html, b.html, or x.html.

    I've searched the javadocs for HttpServletRequest in the hopes it had something to tell me where the request came from, but have found nothing.

    I'm sure there is a simple solution for this, but being new to j2ee and even newer to Spring, I'm stuck in need of a nudge.....

    Thank you,
    jdawg

  2. #2
    Join Date
    May 2008
    Posts
    10

    Default

    I found the partial answer to my question, with this: request.getHeader("Referer"));

    However, in my onSubmit, the referer is the current page I'm on. This is no good! Is this is legitimate solution:

    1. handleRequest finds the referer and passes it to the view as part of the model map.
    2. my form passes that URL back to my controller in a hidden field.
    3. My controller redirects to that URL.

    I will give that a shot, but is that a "best practice" way to do it? These are questions from a dude with years of fat client experience, and weeks of thin client :-)

    Related question, how come "handleRequest" gets called when my submit button is pressed? So the flow is: handleRequest -> show the page, user clicks submit -> handleRequest -> doSubmit

    why?

  3. #3
    Join Date
    May 2008
    Posts
    10

    Default

    Hm.... well it worked so I'm not complaining! :-)

    I will say that I'm now 2 for 2 in spending 1+ hours banging my head, then posting, then figuring it out within minutes after posting......

  4. #4
    Join Date
    Jun 2010
    Posts
    1

    Default

    This is a good use case. I'd like to use it too. Anyone had a solution?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •