0

In struts2 I am getting the bellow error, I know how to fix it just to get rid of the warning which is described in this link link.

FilterDispatcher <<< is deprecated! Please use the new filters!

My problem is, in my existing code I have a custom dispatcher. It works like below

public class TestFilterDispatcher extends FilterDispatcher {
    @Override
    protected Dispatcher createDispatcher(FilterConfig filterConfig) {
        Map params = new HashMap();
        for (Enumeration e = filterConfig.getInitParameterNames(); e.hasMoreElements();) {
            String name = (String) e.nextElement();
            String value = filterConfig.getInitParameter(name);
            params.put(name, value);
        }
        return new TestDispatcher(filterConfig.getServletContext(), params);
    }
}

and then the TestDispacher is handling the error like below. Not sure how I will do this same using the new org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.

public class TestDispatcher extends Dispatcher {
    private static final Logger logger = Logger.getLogger(TestDispatcher.class);

    public TestDispatcher(ServletContext servletContext, Map<String, String> initParams) {
        super(servletContext, initParams);
    }

    @Override
    public void sendError(HttpServletRequest request, HttpServletResponse response, ServletContext ctx, int code,
            Exception e) {
            // have handled some error related problems here
    }
}
A Paul
  • 8,113
  • 3
  • 31
  • 61
  • There's a better solution https://stackoverflow.com/a/16875911/573032 – Roman C Apr 06 '20 at 21:39
  • @RomanC Thank you ! Question, Not sure how to write logic like if error 500 do something, if error 400 do something, with the above url example. – A Paul Apr 08 '20 at 19:00
  • There were similar questions & [answers](https://stackoverflow.com/a/27001380/573032). – Roman C Apr 10 '20 at 21:12

0 Answers0