aspose file tools*
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


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "response.sendRedirect - affecting the table update" Watch "response.sendRedirect - affecting the table update" New topic
Author

response.sendRedirect - affecting the table update

suresh pillai
Greenhorn

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,
suresh
SCJP 1.4
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

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

Joined: Oct 30, 2003
Posts: 23
Here is the coede:-
//----------------------Code
selectstmt = "DELETE FROM AMDB.WOPAC_PID_PATRON_KEYS WHERE PATRON_KEY='"+patronkey+"'";
stmt.executeUpdate(selectstmt);

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.

stmt.close();
m_conn.close();
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 :- Window.open(URL,_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 +"&"
);
*/
}//if
//--------------The program ends here
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: response.sendRedirect - affecting the table update