java - Redirect After Post implementation with only one jsp and one servlet -


i'm little bit confused post-redirect-get pattern. idea:

  • a form sent server post-request , entry in database changed.
  • after post request, correct webpage changed data delivered client using redirect instruction (http 303).
  • the client requests confirmation page. when reloading, done without database change , possibly resultant duplicate content.

in app have got 1 jsp (page.jsp), containing form data , space presenting results. after form being submited, servlet handles data storing , sends data jsp (as request attributes) in order show results. i'm using request dispatcher go jsp. have got 2 questions:

1) should use response.sendredirect ("page.jsp") or request.getrequestdispatcher("page.jsp") - because far can see few different suggestions, i'm using dispatcher.

2) should change correctly implement prg pattern here? according last point - should redirect user confirmation page (although don't want jsp) , redirect again page resuts (page.jsp)? need make sure double-submit problem doesn't appear here, button won't delete data sended using form , f5 button won't crash app.

edit: wrote doget method containing atributes sended jsp - f5 button covered.


Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -