I want to make an entry in the log if my servlet throws ServletException
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException{
try {
} catch (ServletException e) {
log.warn("error");
throw new SerletException(e);
}
Will it recurse? Is it the right way to handle exceptions?
No, there will be no recursion, but wrapping the exception in another one is unnecessary. Just throw
eplain.By the way, a better place for this is a
Filterwhich is mapped on an URL pattern of/*, so that you don’t need to repeat it in all servlets.