This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript 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: 3825

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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: IllegalStateException after canceling file downloading.