Problem on multiple user of a page

Hi I am working on developing a JSP to generate a report in term of Excel sheet for my organization and the brief explanation to this tool and my problem is as follows.

I need to generate Excel sheet based on some inputs.

There are two table used by this tool , XYZ and ABC

Whenever a request is made for this JSP , all entries from table XYZ and ABC are deleted.

Inputs are supplied by an input form within this JSP which receives the input and inserts them into a table 'XYZ'.

Then I need to a execute a Stored Procedure which will get values form this XYZ table and do some calculation and execute query on another database and results are stored in the table 'ABC'.

I generate the Excel sheet fetching the values inserted in the second table 'ABC'.

Every thing runs well until there is only a single request for this JSP.

If one user sends a request and while this request is under processing (which takes around 2 min ) another user send another request for the same JSP. It deletes all the entries (generated by the first request )from the table ABC. That's y when the first request tries to generate the Excel sheet it founds no record from the ABC record or founds records inserted by the second request. That's y generates a faulty report.

So if any one of u have any idea how to overcome this problem it will help me a lot .

Thanking u in advance.

[1434 byte] By [invincibleBoona] at [2007-11-27 1:10:13]
# 1
Use Thread Safe mode
jaydeepswea at 2007-7-11 23:45:31 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Yah I was also thinking about that direction , but dont know how to do that and how to apply thread safe technique.Please it be of greate help for me if u can give me some more help on this and any kind of example. or any tutorial on thread safe ..Thanks a lot.
invincibleBoona at 2007-7-11 23:45:31 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

Sounds like this table ABC only used to hold the data temperarly until the excel file is produced.

In that case you can use a temperary table (if that is supported in the DBMS that you are using) configure the table to erace itself when you commit (Read the DBMS help file to see how it can be done). Then turn autocommit off in your database connections so the changes done in one session will not affect another until you commit.

Another way of doing this is adding another key column to the table ABC. That column will use a unique id for each request so the data entered in different requests will not be mixed up. You can do the cleanup of old records either after generating the excel file or you can leave that to a scheduled clean up process.

Or just lock the tables before start processing and unlock them after generating the file. This will cause the users request to block if there is another request in progress. If the process takes a long time (several mins) this will not be a good idea because the browser will timeout.

LRMKa at 2007-7-11 23:45:31 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...