java - How do I use getOutputStream() and getWriter() in the same servlet request? -
how use getoutputstream() , getwriter() in same servlet request?
you can't use them both @ same time. if first did getoutputstream() can't consequently in same request getwriter() , vice versa. can wrap servletouptputstream in printwriter same kind of writer have getwriter().
servletoutputstream out = response.getoutputstream(); // notice encoding here, important matches of // response.setcharacterencoding(); printwriter writer = new printwriter(new outputstreamwriter(out, "utf-8")); another solution not using getwriter() use printstream similar, don't have type compatibility writer or printwriter.
// encoding again important match of output. printstream print = new printstream(os, true, "utf-8");
Comments
Post a Comment