Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You should not catch and suppress it, but just let it go.</p> <p>I.e. do not do:</p> <pre><code>@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { doSomethingWhichMayThrowException(); } catch (IllegalArgumentException e) { e.printStackTrace(); // Or something else which totally suppresses the exception. } } </code></pre> <p>But rather just let it go:</p> <pre><code>@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doSomethingWhichMayThrowException(); } </code></pre> <p>Or, if you actually intented to catch it for logging or so (I'd rather use a filter for that, but ala), then rethrow it:</p> <pre><code>@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { doSomethingWhichMayThrowException(); } catch (IllegalArgumentException e) { e.printStackTrace(); throw e; } } </code></pre> <p>Or, if it's not an runtime exception, then rethrow it wrapped in <code>ServletException</code>, it will be automatically unwrapped by the container:</p> <pre><code>@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { doSomethingWhichMayThrowException(); } catch (NotARuntimeException e) { throw new ServletException(e); } } </code></pre> <h3>See also:</h3> <ul> <li><a href="https://stackoverflow.com/questions/5299169/how-does-tomcat-prioritize-which-type-of-error-page-to-use/">How does server prioritize which type of web.xml error page to use?</a></li> <li><a href="https://stackoverflow.com/questions/9739472/what-to-do-with-exceptions-why-and-when-does-doget-method-throw-servletexcept/9746657#9746657">https://stackoverflow.com/questions/9739472/what-to-do-with-exceptions-why-and-when-does-doget-method-throw-servletexcept/9746657#9746657</a></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload