What fixed the issue was this making pwriter and outpstrm class members (fields).
private PrintWriter pwriter = null;
private ServletOutputStream outpstrm = null;
And then changin the methods for geting them
@Override
public ServletOutputStream getOutputStream()
{
if (outpstrm == null) outpstrm = new AppServletOutputStream(output);
return outpstrm;
}
@Override
public PrintWriter getWriter()
{
if (pwriter == null) pwriter = new PrintWriter(getOutputStream(),true);
return pwriter;
}
This seems to be what fixed my problem. Since this change the wrapper worked fine. By the way. Who said that you can't call the method forward(req, res) method of the RequestDispatcher class?.