I tried out a modified code sample of HeadFirst
Servlets and
JSP Chapter three Beer Application. Below is the code snippet for the doPost method :
public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
String c = request.getParameter("color");
BeerExpert be = new BeerExpert();
List result = be.getBrands(c);
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println(" Beer Selection Advice
");
out.println("
try : New Tummy Mummy Beer");
request.setAttribute("styles", result);
RequestDispatcher view = request.getRequestDispatcher("result.jsp");
view.forward(request,response);
}
This code prints out the content of whats in the result.jsp and does not render the content that has been written to PrintWriter object got from the HttpServletResponse. Can someone explain this behavior?