For your next posts: You should give some more information on your environment, the technologies and so on. Describe what and why you want to do (e.g. why you do not wan't/can't to use the getWriter() method) and then post it in the correct forum (there is a Servlet forum). In the most cases some code excerpts and the Exception Stacktrace are intersting too....
IllegalStateException saying that, Cannot call getOutputStream() after getWriter().
There is nothing you can do about it. If you check out the API then you'll find that this is documented and expected behaviour:
Writer can be user to send character data and stream can be used to send binary data.You can do both these operations using the outputstream.For binary data use outputstreams as it is and while sending character data ; convert the character to bytes (using the appropriate character set)and then flush that into the stream.In this way you can have functionalities of both by only using outputstream.