res.setContentType("text/html"); PrintWriter out = res.getWriter(); //res.sendRedirect("greetings.html"); <-- not working even if greetings.html is inside the same directory as request URI //res.sendRedirect("/greetings.html"); <-- not working even if greetings.html is in webapp directory //res.sendError(res.SC_NOT_FOUND); <-- not working. // If two lines below are used, getWriter above is commented. // Code below is not working either //RequestDispatcher rd = getServletContext(). getRequestDispatcher("/examples/servlet/HelloWorld"); //rd.forward(req,res); } // doGet ... } I know I've tried that using JavaWebServer and it was working fine. How come it's not working in Tomcat? Thank you very much for the help. [This message has been edited by marlon tan (edited October 13, 2001).]
HI, You say that it's not working but you haven't given us any error messages to work with. Do you get an IllegalStateException after this line?
If so its because you have uncommitted output in the buffer. According to the 2.2 specs - check with the 2.3 - before the target's service() method is called using the forward() method of the RequestDispatcher, the buffer must be reset. Bye,
------------------ Terry Doyle Sun Certified Programmer for Java 2 Platform