This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Servlets and the fly likes sendRedirect after flush without IllegalStateException. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Servlets
Bookmark "sendRedirect after flush without IllegalStateException." Watch "sendRedirect after flush without IllegalStateException." New topic
Author

sendRedirect after flush without IllegalStateException.

Serghei Jelauc
Ranch Hand

Joined: Jul 24, 2002
Posts: 128
Hi all.
It is very strange, but I do not have IllegalStateException in my servlet when I call res.sendRedirect("") method after flushing OutputStream.
Here is my code:

I've tryed it on Tomcat and on Weblogic - the result is the same - I have not been redirected, but I have downloaded file and there wasn't exception.
Could someone explain me why?

Thanks in advance?
[ February 23, 2005: Message edited by: Serghei Jelauc ]

SCJP 1.4 <br />SCBCD 1.3<br />SCWCD 1.4
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
all i wanna say is, read the docs.
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Here it is.

sendRedirect

Sends a temporary redirect response to the client using the specified redirect location URL. This method can accept relative URLs; the servlet container must convert the relative URL to an absolute URL before sending the response to the client. If the location is relative without a leading '/' the container interprets it as relative to the current request URI. If the location is relative with a leading '/' the container interprets it as relative to the servlet container root.

If the response has already been committed, this method throws an IllegalStateException. After using this method, the response should be considered to be committed and should not be written to.

- it is from J2EE Docs
Sim Kim
Ranch Hand

Joined: Aug 06, 2004
Posts: 268
See the tomcat logs . You will see the exception there .
 
GeeCON Prague 2014
 
subject: sendRedirect after flush without IllegalStateException.