How to Avoid Submitting the same form twice ?

Discussions

EJB design: How to Avoid Submitting the same form twice ?

  1. How to Avoid Submitting the same form twice ? (1 messages)

    I want the user to avoid submitting the same form twice by using the browser refresh or back ...

    If TOKENS are used, the user can submit one form only once. But the actual implementing is not known to me.

    Please can any one suggest me and give some simple examples.

    Thanks in advance for helping me

    bye
    kishore kadiri
  2. I think that, using Redirect can solve the prob. This case, i just prevent a record is being saved to database twice when users are trying to refresh the page that have been submitted.

    e.g:

    when i add a new customer - the servlet process for customer has following methods:

    private void eDitCustomer(pk, request) {
      //processing to get the record and output the result
    }

    private void saveCustomer(pk, request) {
     if (pk > 0) {//
       //save the record: update the record to db
     }else{
       pk = addRecord();
     }
     request.getResponse.redirect("customer?pk=" + pk);
    }

    private int addRecord(); //this is processed for add new record and return PK.