Joined: Jun 21, 2003
I just had new findings here. Even though I don't use JSP pages, just servlet, it still throw exactly the same exception.
You can process in two requests. One request(for text html contents) will be handled by jsp. And other request for the image url would be handled by serlvet. Here is the piece of code I hope this can help you.
Hi, My case is a little bit more complicated. I have to write asscii string(html) to the response as well as binary data(image data). I wrapped the HttpServletResponse class and use getOutputStream() to grab the stream. If anything catches your eye, please let me know.
The public void write(String s) method can be used to write html strings. However somewhere I got IllegalException which said that the getOutputStream is already called in Tomcat log file, not in the console. The functionality looks normal though. I have tried to close the stream every time we done writing, however I got try-to-write to a closed stream exception. I have also tried to cache the httpSevletResponse and Response object(such that only one wrapper instance is used for one httpServletResponse object), however it won't work. Please help! Bujin Wang
My case is a little bit more complicated. I have to write asscii string(html) to the response as well as binary data(image data).
Any given response can only write to a character stream or a byte stream. Of course you can send ASCII characters in the byte stream. You should only try substituting your own version of HttpServletResponse if there is no simpler way to accomplish the task. Frequently new programmers get confused about what is going on when a browser displays characters and one or more images. Remember that a web page can be built up of many separate requests. I suggest you create a static web page that looks like what you want, then figure out how to get one or more servlets to provide the various responses. Bill