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

response.sendRedirect - affecting the table update

suresh pillai

Joined: Oct 30, 2003
Posts: 23
Hi all,
I am facing a situation where the response.sendRedirect is preventing table update.
If anyone has faced simillar situation then please let me know the way out.
thanks in advance,
SCJP 1.4
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

I have no idea of the problem you are having. Can you provide more information?
suresh pillai

Joined: Oct 30, 2003
Posts: 23
Here is the coede:-

selectstmt = "INSERT INTO AMDB.WOPAC_PID_PATRON_KEYS ( PID, PATRON_KEY) VALUES ("+pid+","+patronkey+
ri = stmt.executeUpdate(selectstmt);
//At this point I print out the values in the database into the log file.

if (ri == 0) {
System.err.println("Table update Failed, Patron key: "
+ patronkey);
response.sendRedirect(referer + "authenticate=N&"
+ cgistr);
} else {
System.out.println("Table update Successful, Patron key: "
+ patronkey);

//The table gets updated if I comment following part. If not the page gets redirected but the table does not get updated???
I tried to redirect using javascript :-,_self) it works ie. the page gets redirected and the table also gets updated. This means that sendredirect is not emptying the buffer before redirecting to the other page..

/*response.sendRedirect(referer + "authenticate=Y&"
+ "LGNT=1&BC=" + uin +"&"
//--------------The program ends here
Don't get me started about those stupid light bulbs.
subject: response.sendRedirect - affecting the table update
Similar Threads
difrrenc between sendRidirect and forward
handling multiple database requests and updates
soft delete functionality
How to handle transactions when two different databases are involved.
target in response.sendRedirect();