By using the browser, when an error is throwed, i correctly being redirected to the custom error page specified in web.xml file
But why i always see the default 400 error page with it's trace in the output of curl ? I'm missing the type of exception handled (i'm using java.lang.Exception) or other ?
This is the code of the servlet:
package test.company.com;
import java.io.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.lang.Exception;
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
try {
  // stuff here ..
} catch (Throwable e) {
    // Log and throw the superclass Exception 
    LOGGER.log(Level.SEVERE, e.getMessage());
    throw new ServletException();
} 
}
And this is the web.xml config file:
<error-page>  
  <exception-type>javax.servlet.ServletException</exception-type>  
    <location>/error.jsp</location>  
  </error-page>
  <error-page>
  <exception-type>java.lang.Exception</exception-type>  
    <location>/error.jsp</location>  
  </error-page>
  <error-page>
    <error-code>400</error-code>
    <location>/error.jsp</location>
  </error-page> 
  <error-page>
    <error-code>404</error-code>
    <location>/error.jsp</location>
  </error-page> 
  <error-page>
    <error-code>500</error-code>
    <location>/error.jsp</location>
  </error-page>

 
    