Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3666368
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T01:52:19+00:00 2026-05-19T01:52:19+00:00

I’m trying to include a jsp page from a servlet: RequestDispatcher rd = ctx.getRequestDispatcher(

  • 0

I’m trying to include a jsp page from a servlet:

  RequestDispatcher rd = ctx.getRequestDispatcher( jspPage );
  rd.include( req, wrapper );   

But I’m getting the following exception:

java.lang.IllegalStateException: Cannot forward after response has been committed

The problem is with a JSP page that specifies its own default error page through the JSP error tag. The JSP error page can also throw an exception which will trickle up to the application level error page specified in web.xml. So when the jsp page that I am trying to include throws an exception, and the error page throws an exception as well, the include fails.

I have to handle this case gracefully because I am including user-written modules on a page and an erroneous module should display the exception to the user rather than bomb with the IllegalStateException. Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T01:52:19+00:00Added an answer on May 19, 2026 at 1:52 am

    As already hinted in a comment in your previous question, it’s simply too late to change the response. After a X amount of bytes in the response, the response headers will be committed to the client and this is a point of no return. You need to rewrite your JSP’s. They should contain only markup and presentation logic and not any business logic which can throw exceptions.

    If you really can’t refactor the erroneous business code in your JSP’s into fullworthy servlet/business classes, there where they belongs, then your best bet is to increase the HTTP response buffer size in the server config and pray that nowhere a flush() is been invoked before the exception occurs in the JSP and you don’t get OutOfMemoryError failures when it gets busy on your webapp.

    Related questions:

    • How to avoid Java code in JSP files?
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
this is what i have right now Drawing an RSS feed into the php,
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.