If i click a link ia m calling a servlet.
Is there any possibility to track the duplicate request thru filter or something so that i can avoid hitting the servlet?
If i click a link ia m calling a servlet.
Is there any possibility to track the duplicate request thru filter or something so that i can avoid hitting the servlet?
Typically you put some sort of "request identifier" in the link, e.g. a GUID. You either lazily keep track of the identifiers you've already seen (and ignore anything in that set), or keep track of the ones which you've generated but not seen (and ignore anything not in that set).
Do you really want to do this for EVERY request? If you don't, use the first solution in Jon's answer and ignore things that don't have a guid.
You can do this in javascript pretty easy. After any link is clicked, prevent it from being clicked again: (using some YUI):
YAHOO.util.Event.onDOMReady(function(){
function killIt(e){
YAHOO.util.Event.stopEvent(e);
}
var anchors = document.getElementsByTagName('a');
for(var i = 0; i < anchors.length; i++){
YAHOO.util.Event.addListener(anchors[i], 'click', function(e){
var el = YAHOO.util.Event.getTarget(e);
YAHOO.util.Event.removeListener(el, 'click'); // kill existing handle
YAHOO.util.Event.addListener(el, 'click', killIt); // kill any future clicks
});
}
});
you could also make then anchor disabled when you click on it. A little different. Straight forward to only implement this on anchors you want to single-click-only-enable.
There is absolutely no reason to use a huge Javascript framework just to dynamically disable a link.
<a href="/test" onmouseup="this.href='';" />
Done.