Discussions

Web tier: servlets, JSP, Web frameworks: Preventing identical requests from being passed to EJB beans

  1. I am working on a site having a multi-tier architecture.
    I want to prevent requests from going to my back-end EJB beans from my servlet when a user clicks a button more than once. Clicking the button triggers a request from the browser to be send to the servlet which in turn passes it to the back-end EJB bean for processing, which might take some time. In the meantime, if I click on the same button again, it again tries to do the same transaction. Is there any way I can prevent this ?
  2. I use a little javascript for each button. I have a counter initialized to zero and when the button is clicked, I look at the counter and if it is zero, I increment it, then submit. If the counter is greater than zero I do not submit the click. This methods has problems like . . . Users not running javascript are not checked and if the user "stops" the page . . .they can no longer click the button.

    The second problem can be solved by using a timer instead of a counter. Only allow the button to be clicked if 5 secounds has passed since the last click.
  3. Yes, see example: http://dima.dhs.org/misc/LongRunningTask.html

    It illustrates somewhat different thing, also can be applicable to your problem.
  4. Nice work, but you know, it seems to me that creating new Threads on Application Servers ia not allowed, at least in those J2EE compiant.

    I encountered such when I needed to write Singleteon in distributed environment which is to be run by a thread unique among many JVM. I developed a kind of "distributed lock" put in LDAP server ( actually it was a flag saying running the thread or not).
  5. That's exactly what it illustrated - how to create a thread without actually creating one.
  6. Sorry, I was mistaken. You seem to use a kind of application events (scheduled jobs).