Mike Kienenberger wrote:
I'm wondering if the best solution might not be to simply have a
servlet filter that only allowed one request per session to occur at
any one time.
(If you are tired reading all this stuff, go ahead to ====>)
This filter is a good start. We already used such a stuff (its really
easy to implement) and - as long as your business classes wont introduce
a too high latency (or even lock) - it works pretty well.
The only drawback with such a filter is, you serialze every request,
even if they do not have concurrency issues. On pages where you have
multiple dynamically generated images (or iframes .... ok,ok no flames,
I know they are bad ;-) ) you see a performance impact.
Thoug, there is still another drawback of the "double requests" issue
and such a solution:
Even with your filter, the user might only see the last requested page,
all request outputs before are lost - sure, not that a high problem, but
still not that nice.
There are (at least) two issues why double requests happens:
1) The user press a button/link too fast in serie
2) The business logic needs too much time to present a result, and thus
no page transition has been done
The first point is a problem - might be solveable by some javascript
which disables the button/link after the first press. But you have to
think about reenabling it if some client-side validation fails - this
might be a challenge to solve. Also its hard to reenable if your
link/butotn opens a popup.
At least I think this is something a user will learn pretty fast, even
more if we find a solution for 2:
====> And now I'll come to the main request: The second point could be
solved using push technology (or mutlipart response) (where possible).
So if we force a page transition as fast as possible the user might have
no chance to press the button/link again, only one request and the
correct (first requested) output.
We should have immediate page transition and could have a small
javascript in the first response which will print a text like "Your
request will be processed ..." after 2 seconds.
I havent had the time for now to look into such a stuff, but this should
be possible to do, not?
Two questions with this solution:
*) Is it possible to render the first part of the respons using content
type "text/html" but the second part as "application/pdf" ?
*) If - not: We have to find a way to disable the filter, at least by
using some url patterns in web.xml.
Comments?
---
Mario