How do I use getOutputStream() and getWriter() in the same servlet request?
You can use them both, just not at the same time, or rather not for the same response. If you need to use a Writer after you've already started using the OutputStream, just wrap an OutputStreamWriter around the output stream. However if you need to use an output stream after you've already used the writer you can't. You could always get the output stream first, wrap the writer around it as above, do your Writing, flush, then do your output streaming.