aspose file tools
The moose likes JSP and the fly likes OutputStream already obtained error Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » JSP
Reply Bookmark "OutputStream already obtained error" Watch "OutputStream already obtained error" New topic
Author

OutputStream already obtained error

Subha Rangu
Greenhorn

Joined: Jul 23, 2004
Posts: 29
Hi,
I was trying to use OutputStream object in a JSP page.
[Servlet Error]-[OutputStream already obtained]: java.lang.IllegalStateException: OutputStream already obtained

I have done opstream.flush() and opstream.close() before and after the usage resp.

Please advise me what has to be done.
Thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56185
    
  13

Why are you obtaining the output stream in a JSP when it is already exposed to you in the out implicit variable?


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Subha Rangu
Greenhorn

Joined: Jul 23, 2004
Posts: 29
I have to show up an image on a JSP which I get from a method which a Java API returns in byte[] format. That is the reason why I am using outputStream.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56185
    
  13

A few points:

1) Again, the output stream is already available as 'out'.

2) You can't just emit image data into the middle of a page, you must use an <img> tag.

3) The <img> tag should reference a servlet to return the dynamic image data. JSP is a very poor technology choice for returning non-text data.
Julian Kennedy
Ranch Hand

Joined: Aug 02, 2004
Posts: 823
Bubly,

From Tony Morris's response in this thread, you need to ignore the second line.

However, as Bear suggests, this may not achieve what you want. The example in the thread describes how to send a TIFF image to the browser from a Servlet.

Jules
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: OutputStream already obtained error
 
Similar Threads
Exception with displaying image
OutputStream already obtained
Mapping servlets
PDF File Streaming in a JSP
Error 500: OutputStream already obtained