'How to avoid duplicate submission form when Servlet take long time to response

I have a problem in java Servlet. Suppose i have two Servlet and two page(jsp). In index.jsp client enter your mobile number and submit form to sendSMS.do. sendSMS.do must be send SMS to mobile number.

servlet 1: index.do

page 1: index.jsp

servlet 2:sendSMS.do

page2 : success.jsp

in index.jsp :

<form action="/sendSMS.do" method="post">
    <input type="text" name="mobile">
    <input type="submit" value="sendSMS">
</form>

in sendSMS.do:

@WebServlet("/sendSMS.do")
public class RegisterController extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
      String mobileNUmber=req.getParameter("mobile");
      SendMessage sendMSG= new SendMessage();
      //if there are network problems,sendSMS method my be take several minutes for return false
      sendMSG.sendSMS(mobileNumber);
      resp.sendRedirect("/success.jsp");
    }
}

So sendSMS method return true if there is not any problem else return false after several minutes.If client in index.jsp page multiple click on submit button, there are several same request in server.

So How to detect this same request and is there any best practice for this issue?

I read Solving the Double Submission Issue but i want best practice when Servlet take long time to response.

Thanks in advice.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source