File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes how to prevent double clicks on hyper link. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "how to prevent double clicks on hyper link." Watch "how to prevent double clicks on hyper link." New topic

how to prevent double clicks on hyper link.

Fahed Siddiqui

Joined: Jun 24, 2004
Posts: 6

I want to prevent users clicking a hyperlink more than once in a JSP page. Is there any way that can be done? Basically I need to avoid the user from clicking the link multiple times to prevent Tomcat server to process multiple requests.
One acceptable solution for me is that ,if user clicks a link then the page containing that link becomes blank (nothing would be on page so user willnot be able to click it again)and user will feel that as if the response is loading.But how to implement that ?How can I do such thing that is, when a user clicks on a hyperlink the request for processing will be sent to server and the current page will become blank untill the new response page appears.
In simple words i dont want server to process multiple requests as a result of user's clicking on same link and requesting same processing.

Thanks in Advance.

Take care .
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
little you can do. A link is a link is a link and people can click them all they like.
You could make each link link to a piece of Javascript instead that submits to the server only if it's not been submitted before (keeping that status in a JS variable somewhere) but JS can be turned off and it's very messy.

Better to build your serverside application so that it can deal with the situation.

Susanta Chatterjee
Ranch Hand

Joined: Aug 12, 2002
Posts: 102
As I have to leave now, a very quick solution by using Javascript.

If you know the HTML elements, on click of those links, you can hide the elements. We do that many times.
Eric Pascarello

Joined: Nov 08, 2001
Posts: 15385
I agree. Here's the link:
subject: how to prevent double clicks on hyper link.
It's not a secret anymore!