This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

IllegalStateException: Cannot forward a response that is already committed  RSS feed

 
Sujatha Kannan
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey all,
I am getting this error
java.lang.IllegalStateException: Cannot forward a response that is already committed
when I am trying to download a file from the servlet. I tried using both OutputStream and PrintWriter with autoflush set to true and false. Still getting the same error. Any suggestions please.
 
David Hibbs
Ranch Hand
Posts: 374
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't forward a response after you've written anything to it. This includes setting status or other header properties as well as actually writing text to it. So check before you do your forward and make sure that there's nothing being written to the response.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't get both OutputStream and PrintWriter to the same response. That throws an IllegalStateException - just like it says in the servlet API.
Bill
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!