I am using a JSP page to submit data for insert into a database.
If the refresh button (in the browser IE5) is clicked, the data is resent and inserted into the database again. How can this be prevented?

Luigi Viggiano

I usually avoid this problem separating "view" pages from "controllers". The form is displayed in a "view" page that submit data to the controller, then the controller forwards to a result page (that can be another view). In this way, the page displayed on the client doesn't do anything else than displaying something, and refreshing doesn't give any problem.

   |                    | (sometime can
   | View (with a form) |  be implemented
   |____________________|  with plain html)
             | (submit data)
   |                    |
   |     Controller     |  (can be 
   | (handles data      |   a "mute" JSP
   |  manipulation and  |   or a servlet 
   |  persistence )     |   that doesn't 
   |____________________|   give any output)
             | (forward)
   |                    | (can be a JSP
   | View (result page) |  displaying 
   |  with eventually   |  inserted data)
   |  another form      |
So, refreshing a "view" page doesn't imply any submit or any data storage, because views are incharged just to "display" something, and controllers cannot be refreshed by the client because they are invisible to him. Sometimes view can be implemented just with plain html without using JSP