Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

response.sendRedirect - affecting the table update

 
suresh pillai
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have no idea of the problem you are having. Can you provide more information?
Dave
 
suresh pillai
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic