Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1811
  • Last Modified:

Stopping parameter resubmit on refresh

Hi,

Is there a way to stop parameters being resubmitted when a jsp page is refreshed. The parameters are being sent by GET but out of interest is there a way that could do it for POST or even both? Thanks.

-Sam
0
samblake
Asked:
samblake
1 Solution
 
KuldeepchaturvediCommented:
well there is no sure shot way of doing it.... but we usually employ a switch method... i.e. we have a hidden field in every form of the system... it starts with a zero....... and when first request hits the server it goes in the session as 0.... now when the request is finished we bump it by one.... so next form gets it as 1.....
so next time around when the request comes back to us... we check if the session value is 1 less then the recieved one...
If not its considered as a resubmit/refresh....

try that if that works for you...
0
 
kennethxuCommented:
what Kuldeep suggested is refered as using token, Struts has build in token support.

another approach would be after processed the request. do response.sendRedirect() to the said jsp page (maybe itself), EE is taking this approach for this post thread.

I'm not saying which one is better. in fact token always work. sendRedirect() is easier but restricted by the why your jsp page is coded.
0
 
samblakeAuthor Commented:
Yep, just put sendRedirect(request.getRequestURI()) and it worked great. Thanks.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now