Hello world
in a servlet I'm processing a forward :
getServletConfig().getServletContext().getRequestDispatcher("page.jsp").forward(request, response);
and then in the same servlet i'm wrinting in the output stream:
strResult="hello";
ServletOutputStream servOutputStream;
byte[] bytRetorno=strResult.getBytes();
response.setContentType("text/plain");
servOutputStream =response.getOutputStream();
servOutputStream.write(bytRetorno);
servOutputStream.close();
when I execute that servlet I've got the following error message:
Error Message: ERROR: Cannot set header. Response already committed.
Error Code: 500
Target Servlet: null
Error Stack:
java.lang.IllegalStateException: ERROR: Cannot set header. Response already committed.
at com.ibm.servlet.engine.srt.SRTServletResponse.setHeader(SRTServletResponse.java:476)
at com.ibm.servlet.engine.srt.SRTServletResponse.setContentType(SRTServletResponse.java:438)
at com.ibm.servlet.engine.webapp.HttpServletResponseProxy.setContentType
Can somebody help me with that please, I want to keep the two actions (forward and writing in the servlet outputstream).
Thanks.