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

  • Home
  • SEARCH
  • 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 8991431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:43:29+00:00 2026-06-15T22:43:29+00:00

For exceptions thrown while handling a request, Spring has a number of different ways

  • 0

For exceptions thrown while handling a request, Spring has a number of different ways to register exception handlers. Is there a way to apply similar exception handling when the exception is thrown while rendering a view? At a minimum I’d like the ability to perform some logging.

  • 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-06-15T22:43:31+00:00Added an answer on June 15, 2026 at 10:43 pm

    The problem is that exceptions thrown during View rendering cannot do an awful lot. In particular, they typically can’t render a HTML page containing an error report … or even send a 5xx response … because the response will typically have “committed” before the exception is thrown.

    So the best you can do (probably) is:

    • create a wrapper for the View object that catches and logs the exception, or
    • do the logging in a servlet filter,

    But the chances are that the web container can be configured to log uncaught exceptions anyway.

    UPDATES

    I just noticed spring’s HandlerInterceptor class exposes an ‘afterCompletion’ method which will be invoked when exceptions are thrown. Any thoughts as to the benefits of using this vs. a filter?

    Try it and see. 🙂 But given the following, I doubt that it will work.

    Using a filter or interceptor does not work for exceptions thrown while rendering a jsp. It does print to err out:

    Dec 16, 2012 12:18:03 PM org.apache.catalina.core.ApplicationDispatcher 
        invoke SEVERE: Servlet.service() for servlet jsp threw exception
        javax.el.PropertyNotFoundException: Property 'fooo' not found on 
        type java.lang.String" 
    

    Unfortunately the exception is not propagated upwards to the filter. I’d like to add my own logging which sends out error notifications and logs additional information about the failed request. Keeping an eye on log files to spot errors isn’t a good option.

    1. The chances are that the log message is actually produced using the logging subsystem. If it is, you can use the logging configuration to add your own handler for JSP engine logging events and send out special notifications.

    2. The fact that the exceptions are 1) being thrown during JSP view rendering, and 2) the JSP engine is not propagating them means that (IMO) it is unlikely there is a way for you to catch them.

    3. The other option is to set up a scanner for the log files … as part of your general system monitoring.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While playing with exception handling in Java I noticed that no exception is thrown
I've never been completely happy with the way exception handling works, there's a lot
While designing a new WPF application I noticed exceptions not being thrown during data
While accessing our own website in Java code, an exception is thrown: javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException:
I have a HttpModule in C# 2.0 which handles exceptions thrown. Whenever the exception
I'm developing a demo program that shows the impact of different ways of handling
Short form: How do you throw exceptions (or do nice, clean exception handling; or
I developed a sample mail program in Java. While sending mail, it throws exception
while looking at some code I stumbled onto: throw /*-->*/new std::exception (//... and I
In C#, I can use the throw; statement to rethrow an exception while preserving

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.