File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Transaction Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Transaction Problem" Watch "Transaction Problem" New topic

Transaction Problem

kiran mahavir
Ranch Hand

Joined: Jan 09, 2001
Posts: 35
hi all,
Please Suggest how to approach the following problem,
In an application(which is implemeted with JSPs and servlets) developed by me, the user has to fill up several pages with information to complete a task.The task gets executed when he finishes with the last page.That task is a bit complex(which involves accessing DB etc). After the task is completed the application responds with a thank you message.
Now my problem is, if the user submits the last page several times(slow response due drop in net speed or something like that) before the task is completed,the task is redone that many times.
How to overcome this repeatetive execution.If the task is still in execution, the application should ignore the request instead of redoing it.
Thanx in advance
Axel Janssen
Ranch Hand

Joined: Jan 08, 2001
Posts: 2164
Good news. You are not the first, who encountered this problem.
It is mentioned for example in the J2EE-Design pattern books by sun.
Favoured solution by mainstream is the token solution: Dave Soto explained it quite well for my taste:
(search for token in this forum, and you will get some references among the most recent posts).

Joined: Apr 12, 2002
Posts: 1
Hi ,
Iam not sure whether I understand correctly. But If the users submit the last page via a buttin(HTML) then u can disable after its hit once.. which will eventually avoid submitting the same again.
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63858

The client-side solution proposed by somepal (be prepared to change your name) is less optimum than the token solution because it relies upon javascript that needs to be different in various browsers, and can't protect against a resumbit via refresh and the back button.

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: Transaction Problem
It's not a secret anymore!