Hi Everyone,

I am brushing up on my servlet programming after a long lay off. I was working through this book and came across the perils of using sendRedirect after commiting the response. My understanding according to the book and the 2.4 servlet api is that if you call the sendRedirect method after outputting something with the PrintWriter and flushing it should throw an Illegal exception, right? I want to know if anyone out there also noticed this or am I doing something wrong?
Tomcat version: 5.0.19
OS: Mac OS X 10.3.3
J2SDK: 1.4.2_03


My code:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class RedirectException extends HttpServlet{

public void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException,
IOException {



PrintWriter writer = response.getWriter(); writer.println("<HTML>"); writer.println("<BODY>"); writer.println("Company News!!"); writer.println("</BODY>"); writer.println("</HTML>"); writer.flush(); response.sendRedirect("http://news.bbc.co.uk";);




} }

What is happening is that the browser is displaying Company News!

Thanks,
Umesh


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to