Two Laptop Bag*
The moose likes Servlets and the fly likes IllegalStateException after canceling file downloading. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "IllegalStateException after canceling file downloading." Watch "IllegalStateException after canceling file downloading." New topic
Author

IllegalStateException after canceling file downloading.

pawan chopra
Ranch Hand

Joined: Jan 23, 2008
Posts: 410

Hi All,

I am providing a file download option to the user in my web-application. Suppose user selects cancel the downloads, I am getting IllegalStateException. I am using tomcat and spring MVC. Kindly let me know how to handle this exception.

here is my code which downloads the file:



Pawan Chopra
SCJP - DuMmIeS mInD
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

It looks like you handled it. If you wanted to do something else, you could also do it in the 'catch' block.
pawan chopra
Ranch Hand

Joined: Jan 23, 2008
Posts: 410

I don't want that the exception thrown should display on the tomcat console. But it is showing.
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3816

I don't want that the exception thrown should display on the tomcat console. But it is showing.


That's because your logger may have configured to do so.


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Mohamed Inayath
Ranch Hand

Joined: Nov 22, 2004
Posts: 124
The IllegalStateException could be because you are trying to close (close(output); ) the resource(resource.close();).

I believe the response is committed and you are trying to close.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

I agree with Vijitha Kumara: if you don't want it logged, then don't log it.
pawan chopra
Ranch Hand

Joined: Jan 23, 2008
Posts: 410

Thanks to all of you, my mistake I was trying to open the response output stream again in some other method
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: IllegalStateException after canceling file downloading.
 
Similar Threads
bytearray image decoding
A problem with servlet file transfer
Opening a PDF
What's the best way to download files from a web app?
Video Player