• 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
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Problem with JSP error page  RSS feed

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!!!
Posts: 67257
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.
Posts: 1845
  • 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.
If you live in a cold climate and on the grid, incandescent light can use less energy than LED. Tiny ad:
ScroogeXHTML - small and flexible RTF to HTML converter library
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!