Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I expect this is already solved in some way by Struts - so best check struts docco. If i were you i'd write an ExceptionFilter that can wrap your servlet calls:</p> <pre><code>import java.io.IOException; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletResponse; import org.apache.log4j.Logger; public class ExceptionFilter implements Filter{ private static final Logger logger = Logger.getLogger(ExceptionFilter.class); private ExceptionService exceptionService = null; @Override public void destroy() { exceptionService.shutdown(); } @Override public void doFilter(ServletRequest rq, ServletResponse rs, FilterChain chain) throws IOException, ServletException { try { chain.doFilter(rq, rs); // this calls the servlet which is where your exceptions will bubble up from } catch (Throwable t) { // deal with exception, then do redirect to custom jsp page logger.warn(t); exceptionService.dealWithException(t); // you could have a service to track counts of exceptions / log them to DB etc HttpServletResponse response = (HttpServletResponse) resp; response.sendRedirect("somejsp.jsp"); } } @Override public void init(FilterConfig arg0) throws ServletException { // TODO Auto-generated method stub exceptionService = new ExceptionService(); } } </code></pre> <p>and add this to your web.xml:</p> <pre><code>&lt;filter&gt; &lt;filter-name&gt;ExceptionFilter&lt;/filter-name&gt; &lt;filter-class&gt;com.example.ExceptionFilter&lt;/filter-class&gt; &lt;/filter&gt; &lt;filter-mapping&gt; &lt;filter-name&gt;ExceptionFilter&lt;/filter-name&gt; &lt;servlet-name&gt;MyMainServlet&lt;/servlet-name&gt; &lt;/filter-mapping&gt; </code></pre> <p>then add filter mappings for all your servlets.</p> <p>Hope that helps.</p>
    singulars
    1. This table or related slice is empty.
    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.
    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