Servlet response already use stream, Writer not possible
Joined: Jan 17, 2002
I am trying to obtain an image byte from the Session Context, Then i would like to display this image, The code segment is below
But unfortunately i am getting the following exception
Please how can i resolve this
Joined: Mar 22, 2005
Where is this code located - in a JSP page? I'm guessing it is, since you are posting to the JSP forum. A JSP page really can't (and shouldn't) use the output stream. If the response consists of an image you need move this code to a servlet.
JSP compilers will often add characters to the output stream going to the browser. Since the primary intent for JSP is textual output (Mainly HTML or XML) these characters aren't a problem. If you're trying to write binary data to a browser, however, they will become a problem. This is why it's best to do this with a servlet.
Thanks folks ,I used a servlet and it worked well. The code i earlier tried was straight from the myfaces example i downloaded from Myfaces. its contained in the file_upload.java file and it used a JSP to emit images which is wrong like you two gentlemen pointed out and this i agree with