response.sendRedirect problem in Tomcat 5.0.18 2004-02-01 - By Ben Souther
Back You'll need to structure your code so that you either write to the out stream or perform a sendRedirect. There has never been a version of Tomcat that would allow otherwise. This is the same in PHP, ASP, and I imagine any other web scripting language.
A sendRedirect does nothing more than send back a bodyless header with a "Location: url" parameter.
You can't send a header once you've started writing to the body of the message. You also can't write to the body after sending a redirect (which is why you need to add a "return" statement just after the redirect).
On Sunday 01 February 2004 06:55 am, you wrote: > Hi Ben, > > Thanks for your assistance, I added "return ;" statements directly after > the redirects but this didn't stop the errors. I am currently having the > code checked and will let you know what eventuates. > > Should there be no "out.print" statements above the "response.sendRedirect" > lines in the jsp code ? > There are also "out.write" statements in the jsp code above the redirect > lines, could these also cause a problem ? > > The code was not erroring like this when using Tomcat 4.1.24 or 5.0.16, do > you think this is due to Tomcat 5.0.18 being more strict with syntax ? > > Thanks for your time, > > Regards > Anthony > > > From: Ben Souther <bpsouther@(protected)> > > >Reply-To: bpsouther@(protected) > >To: "Tomcat Users List" <tomcat-user@(protected)> > >Subject: Re: response.sendRedirect problem in Tomcat 5.0.18 > >Date: Sat, 31 Jan 2004 23:53:41 -0500 > > > >On Saturday 31 January 2004 11:32 pm, you wrote: > > > at org.apache.jsp.product_jsp._jspService(product_jsp.java:283) > > > >If you go into your work directory, and look at product_jsp.java line 283, > >you will see exactly what's causing the problem. > > > >Without seeing your code, I can't be sure what the problem is but 99% of > >the > >time when I see an illegal state exception it caused by one of two things. > > > >Either you've written someting to the out stream before redirecting > >(setting > >content type or any out.print statements) or you didn't put a return > >statement just after the redirect. > > > >If neither of these is the case and you can post your code, attach your > > JSP and the product_jsp.java code I'll take a stab at it. > > > >-Ben > > > >-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------ > >To unsubscribe, e-mail: tomcat-user-unsubscribe@(protected) > >For additional commands, e-mail: tomcat-user-help@(protected) > > __ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ __ > Hot chart ringtones and polyphonics. Go to > http://ninemsn.com.au/mobilemania/default.asp
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------ To unsubscribe, e-mail: tomcat-user-unsubscribe@(protected) For additional commands, e-mail: tomcat-user-help@(protected)
|
|