The Artima Developer Community
Sponsored Link

Java Answers Forum
response.sendRedirect problem

3 replies on 1 page. Most recent reply: Aug 27, 2004 9:54 PM by ASP2JSPMig

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 3 replies on 1 page
ASP2JSPMig

Posts: 7
Nickname: nhamdan
Registered: May, 2004

response.sendRedirect problem Posted: Aug 26, 2004 5:06 AM
Reply to this message Reply
Advertisement
Hi all i have a strange probelm in my page i have a response.sendRedirect statment in a begining of the page , when the page load i ask of some condifition if true then redirect and the following error appears with me !!
----------
Response has already been committed, be sure not to write to the OutputStream or to trigger a commit due to any other action before calling this method.
------------

below is my code :

if (strStatus.trim().equals("completedesignc")){

vecRs = con.executeSelect("select * from PRT_BLD_MODF where PRT_BLD_MN_ID="+ bldDtlID +" and status = 0" );

if (vecRs.size()>0 && oprMode.trim().equals("addnew")){

response.sendRedirect("bldFrmList.jsp?oprmode="+ oprMode +"&caseid="+ caseID +"&appid="+appID +"&strMsg=3");
out.flush();
return;

}
}


Any help please !!!


Lynn Hollerman

Posts: 67
Nickname: gmholler
Registered: Mar, 2002

Re: response.sendRedirect problem Posted: Aug 26, 2004 12:32 PM
Reply to this message Reply
I don't think you need the "return;" statement (but then again, I'm not sure just what you're trying to do); come to think of it, Java may have a problem with that "out.flush();" after the redirect, too...

Lynn.

Kondwani Mkandawire

Posts: 530
Nickname: spike
Registered: Aug, 2004

Re: response.sendRedirect problem Posted: Aug 26, 2004 4:35 PM
Reply to this message Reply
In addition to the above suggestions, just wanted to
mention that sometimes if you're using a debugger
it tends to misbehave. So what I do is stick print
statements to see where the program crashes.
If you already do this then sorry for bringing this up
but something like this:

System.out.println("prog reaches here tag 1");
response.send(blah blah blah);
System.out.println("successful response send");
flush.out();
System.out.println("flushed");
return;

/** I'm really confused at the return statement though
** return what? What's your method signature..
** When you call the method, you may want to stickin
** a println after that call too (to see if you do
** successfull return what ever it is you are meant to
** be returning
**/

Good luck man, I hope this helps.

Spike

ASP2JSPMig

Posts: 7
Nickname: nhamdan
Registered: May, 2004

Re: response.sendRedirect problem Posted: Aug 27, 2004 9:54 PM
Reply to this message Reply
Thanks all for the replies .. it was a strange problem and he solution was strange also !! i have put the response.sendRedirect statment at the first of the page and it works so i kept make be down until it reached to some line and crashed .. and what i done that i put all my logic not at the body before the <head> .. and it worked !!! its strange but thank you any way

Flat View: This topic has 3 replies on 1 page
Topic: Why is this code not working Previous Topic   Next Topic Topic: Java applets

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use