File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes IllegalStateException:........ Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "IllegalStateException:........" Watch "IllegalStateException:........" New topic


Harish Kashyap
Ranch Hand

Joined: Jun 14, 2000
Posts: 118
hi all,
i'm trying to develop an upload-download application through jsp. its giving me following error while downloading.

it says IllegalStateException. basically IOException.
says OutputStream already in use for this request.
what i'm doing is when i click on link, it calls a jsp which reads from a file and writes using the printwriter.
for doing this let's say image download.
i changes the content type of response object to image/gif
then i set the content length attribute. then i write the image using printwriter.
it gives the above mentioned exception.
can ne 1 help me.
Peter den Haan
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
Originally posted by Harish Kashyap:
i'm trying to develop an upload-download application through jsp.

Wrong tool for the job. JSPs are only fit to produce text-based output formats. Use servlets. There's no advantage in using a JSP anyway.
You're getting an IllegalStateException because the JSP engine has already obtained a response output stream and wrapped a JspWriter around it. You cannot get a different writer.
- Peter
I agree. Here's the link:
subject: IllegalStateException:........
It's not a secret anymore!