Author
IllegalStateException after canceling file downloading.
pawan chopra
Ranch Hand
Joined: Jan 23, 2008
Posts: 361
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
posted Apr 27, 2009 01:35:46
0
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: 361
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: 3670
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
posted Apr 27, 2009 02:31:07
0
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: 361
Thanks to all of you, my mistake I was trying to open the response output stream again in some other method
subject: IllegalStateException after canceling file downloading.