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 may be using version 2.1 of the servlet spec. The printwriter output is not buffered, so when you called flush(), the redirect header can no longer be set. Why don't you just reverse it by having your redirect header before sending any output to the client.
Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
When the flush method is invoked the response will be committed i.e. the contents written will be sent to the client .In such a case it is illgal to invoke sendRedirect() method. So IllelagalStateException will occur.