Preventing multiple HTTP request to a Servlet

Posted on 2003-03-26
Medium Priority
Last Modified: 2013-11-24
My problem is, I have a user which sometimes clicks multiple times on a HTTP link. When they do this it causes multiple requests/threads to be sent to the Servlet. All of these requests are fully processed by the backend.

I know one way of preventing this from happening, i.e. JavaScript, but this is unacceptable for this solution. I also tried setting a parameter in the session and returning from the method when it is set, but this just generates a blank page on the second which arrives before the first has finished.

Any help or suggestions would be greatly appreciated.

Kindest regards,
Question by:dglancy
  • 2
LVL 35

Expert Comment

ID: 8210534
 Thsi article explains how you can avoid duplicate form submissions. You might be able to adapt it for multiple clicks on links.
LVL 35

Accepted Solution

girionis earned 1500 total points
ID: 8210536

Expert Comment

ID: 8210884
public void doPost(HttpServletRequest req, HttpServletResponse resp) {
    if (req.getSession().getAttribute("processing") != null) {
        req.getSession().setAttribute("processing", new Object());
        try {
            //process the request
        } finally {
            req.getSession().setAttribute("processing", null);

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Don’ts and Dos are two important end products of software testing basics that a tester needs to regard. This article attempts to explain the principles of both.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This video teaches viewers about errors in exception handling.
Suggested Courses
Course of the Month9 days, 15 hours left to enroll

569 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question