Only 44 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!

Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with JSP error page  RSS feed

Gianluigi Leonardi
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi to all,
i'm new in coderanch! :)

I've a strange problem with the JSP's error page, i'll expose it.

My error page (located in Eclipse Workspace in "/project/WebContent/resources/error.jsp") is very simple, like this:

So, in the pages in which there may be exceptions (example xxx.jsp in "/project/WebContent/xxx.jsp") i declare something like this:

Well, the problem is that when an exception occurs, it is correctly captured by jsp (in Console appears the log with the exception's message printed from the error.jsp), but the error.jsp page is not rendered in the Browser... exactly, in the Browser appears the page in which the exception occurs (xxx.jsp), but loaded for half, like if when the exception occurs, the browser go to crash and isn't redirected to error.jsp

I've also tried to render the error.jsp calling directly it's url from the browser and is correctly rendered, then the error.jsp hasn't structure problems.
So, where do you think could be the problem?

Tnx a lot to all!!!
Bear Bibeault
Author and ninkuma
Posts: 65824
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All of that is very old technology. You should not be putting Java code in modern JSPs. That's been obsolete for over 13 years!

You want to add an error handling servlet to your web app.
Stefan Evans
Posts: 1834
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Seeing half your your generated page rather than the error message sounds like the page has started sending itself to the browser before the error has occurred.
How big a jsp page are we talking about?
What server are you using?

Basically, JSP pages have a buffer (default size is 8k) which they generate into. It starts sending that back to the client when the page is complete, or the buffer fills up (whichever occurs first)
If an error occurs BEFORE the response is sent back, the server can cancel sending, and instead send your error page.
Once the response starts sending though, thats it, you're committed, and you can't change it.

That sounds like it might be happening here.
One thing you can try doing is increasing the buffer on this page:

However as Bear has already mentioned, this is less used nowadays. Most of the logic that generate errors/exceptions should be in java code in a servlet rather than a JSP.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!