Q: PRG Pattern

Hi,

I am trying to realise the PRG Pattern in a simple example web app. Do you think i "solve" this pattern with this approach?

-->

I have got a register.jsp file with a form which submits data per POST to a servlet. This servlet (Controller) "call" the Model to save the data into the DB and resp.redirect to a resultpage with this snippet:

resp.sendRedirect("pages/results/registerResult.jsp?id="+id+""");

With the id I can lookup the DB to display the proper registered data. Perhaps I should use the requestScope or sessionScope to store the tempData which will be shown on the resultpage?

If the registerResult.jsp appears and the user hits the refresh button nothing happens (no POST warning message).If the user hits the back button and tries to resubmit the same data he got a validation error like "user already exists".

<--

Is this enough to avoid issues when users spam "browsers" refresh/back/forward button or do I have to take care of more pitfalls?

I hope you can help me :)

Cu

Alex

[1148 byte] By [Troilusa] at [2007-11-27 10:45:29]
# 1

>Perhaps I should use the requestScope or sessionScope to store the

>tempData which will be shown on the resultpage?

You would have to use sessionScope. Sending a redirect forces a new request from the browser, so request parameters/attributes are lost on a redirect.

Hitting refresh refreshes the "get" request, which results in no issue.

Pushing back and then request, would resend the "save" request, which is what you are trying to avoid.

The PRG doesn't prevent the issue, it just makes it harder for a clueless n00b to break the system.

evnafetsa at 2007-7-28 20:13:13 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

> Pushing back and then request, would resend the "save" request

One clarification: this will not happen automatically. The client *have* to submit the form again by manually invoking the button/link to resend the request.

BalusCa at 2007-7-28 20:13:13 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

>The PRG doesn't prevent the issue, it just makes it harder for a clueless n00b to break the system.

Could we do more to prevent that these "users" are breaking the system? I thinkif I have validation on the first form, the user could not resend his data without modifing some values (like email adress).

Cu

Alex

Troilusa at 2007-7-28 20:13:13 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...