Struts: Previous pages preserves old data

P

PC Leung

Hello

If a user fills in a form and presses a submit button,
the form is cleared. Record is inserted into database.

However if user clicks the "Back" button on the IE toolbar,
previous form data still there. If user now clicks
the submit button again, same record tries to insert into database.

Are there anything can be done to manipulate the "back" button
so that clicking it resulted in going back directly to main menu
or
other way to prevent same record from trying to insert into database?

Thanks
PC Leung
 
M

Murray

PC Leung said:
Hello

If a user fills in a form and presses a submit button,
the form is cleared. Record is inserted into database.

However if user clicks the "Back" button on the IE toolbar,
previous form data still there. If user now clicks
the submit button again, same record tries to insert into database.

Are there anything can be done to manipulate the "back" button
so that clicking it resulted in going back directly to main menu
or
other way to prevent same record from trying to insert into database?

Thanks
PC Leung

You can try all sorts of tricks to prevent users from going back, like
running the page in a popup and disabling navigation using javascript,
setting response headers to prevent caching etc ... none of them are
guaranteed to work unfortunately.

The safest way is to detect and handle duplicate requests. You can do that
in Struts using tokens. Check the docs, in particular the saveToken(),
isTokenValid() & resetToken() methods of the struts Action class
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top