I use a system where a servlet sets a 'token' (a random number attribute)
which the JSP must return (using a hidden form field attribute) to the
servlet when the form is submitted.

The servlet keeps a copy of the token. The servlet checks the token sent by
the JSP with its own (current) copy. If the two match, the form is
processed, otherwise it is rejected.

When the servlet processes a form-submit request, it always discards the
current token, so that it can never be reused.

It means, of course, that you have to design things so that the same
'controller' servlet is used to both display the JSP (after it sets the
token) and then to handle the form submit from it.

It works for me.

Harry Mantheakis
London, UK


> Hi,
> 
> I have a problem where a user enters data into a form and then submits this
> to the server, which in turn wrights this content into a database.
> 
> The problem I have is that if the user then refreshes the page via F5 then
> it adds the same data in again.
> 
> Is there any way to ensure that this does not occur.
> 
> Any help would be greatly appreciated.
> 
> Thanks
> 
> Pete
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to