can we do getwriter and forward in a single servlet

Posted by karanits on Stack Overflow See other posts from Stack Overflow or by karanits
Published on 2010-06-03T08:17:21Z Indexed on 2010/06/03 11:34 UTC
Read the original article Hit count: 179

Filed under:
|
|

Lets say my form called a servlet. I would do some processing in it. In the servlet i want to print something on the page. for that i used

PrintWriter out=response.getWriter();
 out.println("some text here");

then further in the servlet i did some more form processing which works fine and after that i want the servlet to be forwarded to a jsp page. For this i used

RequestDispatcher rd = request.getRequestDispatcher("/somepage.jsp");
 rd.forward(request, response);

the problem comes here. the text

some text here

gets printed, but the servlet doesn't forward request to the jsp page, as if the code doesn't run.

© Stack Overflow or respective owner

Related posts about jsp

Related posts about servlets