This week's book giveaway is in the HTML Pages with CSS and JavaScript forum.
We're giving away four copies of Testing JavaScript Applications and have Lucas da Costa on-line!
See this thread for details.
Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

response.sendRedirect() from Dynamic Include

Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi group,

I have a problem while using response.sendRedirect() in my Jsp Page.
I have a Jsp page, which has static and dynamic includes
In one of the dynamic include file, i am using response.sendRedirect() to redirect to another page.
A runtime IllegalStateException is thrown in this case,
as It says the response has already been committed.
But if the response.sendRedirect() works fine when used directly in the main JSP Page.
that too.. when the buffer size is increased
1. What is the reason behind this exception.
2. what would be a better Solution this problem?

thanx in advance
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"sendRedirect() and sendError() methods will have the side effect of committing the response, if it has not already been committed, and terminating it. No further output to the client should be made by the servlet after these methods are called. If data is written to the response after these methods are called, the data is ignored."
But if you have commited the response and have called sendRedirect() method, then that will result in IllegalStateException.
You can use this method "response.isCommitted()" to check if response is already commited or not.
Hope this helps.
Be reasonable. You can't destroy everything. Where would you sit? How would you read a tiny ad?
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic