Thanks for the javascript code, it works perfect
for forms, for hrefs you should call it within the onClick
method.
<a href="..." >
Anyway. We've implemented our own
"SingleThreadModel" to queue all the request but only per user and it works
pretty good. We are using a reentrant lock and we check it within
service() method of the servlet we want to prevent start processing
newer requests of the same user. It is cool and easy to understand:
if (mtx == null)
{
mtx = new ReentrantLock();
httpSession.setAttribute(ATTR_SESSION_MUTEX, mtx);
}
mtx = new ReentrantLock();
httpSession.setAttribute(ATTR_SESSION_MUTEX, mtx);
}
try {
if (!mtx.attempt(20000)) {
showTimeOutMessage(httpServletRequest, httpServletResponse);
return;
}
if (!mtx.attempt(20000)) {
showTimeOutMessage(httpServletRequest, httpServletResponse);
return;
}
super.service(req,
res);
}
catch (InterruptedException e) {
Thread.currentThread().interrupt();
showTimeOutMessage(httpServletRequest, httpServletResponse);
}
finally {
mtx.release();
}
}
catch (InterruptedException e) {
Thread.currentThread().interrupt();
showTimeOutMessage(httpServletRequest, httpServletResponse);
}
finally {
mtx.release();
}
I would add it to the specification cause
SingleThreadModel by itself is almost useless.
Best Regards.
Diego.
