File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Redirecting to jsp without caching the data Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Redirecting to jsp without caching the data" Watch "Redirecting to jsp without caching the data" New topic
Author

Redirecting to jsp without caching the data

Bhavesh Sangwan
Ranch Hand

Joined: Aug 08, 2012
Posts: 56
I coded a JSP which is processed by an Action and then redirected back to same JSP on success/failure. Actually this jsp inserting data into database successfully and returning to the same jsp happily after insertion...

but


when I press refresh button after returning, it inserts previous data again into database even without clicking on submit button. And I noticed that when I'm coming on same JSP after successful insertion, it doesn't change its URL as it was in very first request....

my jsp url is- http://localhost:8080/ManageMyAccounts/manage_account.jsp

and after clicking on submit button, it inserts record in DB and return on same jsp but with URL- http://localhost:8080/ManageMyAccounts/transaction.do

and now if I press F5/ refresh button, it again inserts that previous data into DB...

So how to handle this ?

I made my best efforts explaining my problem to you. I hope you understood what I want. Now Please help....

Thanks..!
Bhavesh Sangwan
Ranch Hand

Joined: Aug 08, 2012
Posts: 56
Wow... ! Nobody is here to help.... great....
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39535
    
  27
It sounds as if the form submit uses a GET, not a POST, or otherwise it should have popped up a dialog asking you to confirm that you want to resubmit the form.

It also sounds as if you're not using the Post-Redirect-Get pattern after the form submit.


Ping & DNS - updated with new look and Ping home screen widget
Bhavesh Sangwan
Ranch Hand

Joined: Aug 08, 2012
Posts: 56
JSP code


Action Mapping in struts-config


Action class


And URL of jsp page is also not changes after redirecting after action completed.....
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Redirecting to jsp without caching the data
 
Similar Threads
How to clear a request attribute/entry
Refresh problem
Data of previous form gets submitted on refersh
How to identify when refresh button of browser or f5 is pressed
How to Return to Previous page that was request by Post Form Submitting after Login?