First,I want to show "hello" on browser, Next,redirect to www.yahoo.com but,the browser shows only "hello",don't redirect to www.yahoo.com. If del out.flush(),browser can redirect to www.yahoo.com.But don't show "hello". who can tell me, why? thanks.
you can't call "flush" before calling sendRedirect. as a general rule, flush means your response is over, nothing more. no more changes in status code, headers, or response-body. Otherwise, IllegalStateException. Tomcat doesn't give your that exception, because it is lenient. It just ignores the output after flush. Kyle
This line of code response.sendRedirect("http://www.yahoo.com"); after out.flush() does produce the IllegalStateException in Tomcat also. Check your log file (C:\jakarta-tomcat-4.0.3\logs\localhost_log_date.log) The exception is logged in there. Since the response is already commited , there is no way to send this exception to browser again. This is the reason you do not see any exception displayed in browser. If you try to make a try ... catch block then you can realize that the IllegalStateException is reaised indeed.
Regards, Maha Anna [ November 30, 2002: Message edited by: Maha Annadurai ]