Preferred way to handle Java exceptions in ServletContextListener

前端 未结 4 1831
借酒劲吻你
借酒劲吻你 2020-12-29 06:18

For servlet lifecycle stuff, what do you guys recommend doing in response to an exception...

For example,

public class Foo implements ServletContextL         


        
4条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-29 07:02

    When you catch an exception, you might want to consider setting a ServletContext attribute to indicate that an error has been encountered. That way, if the container has not disabled the app, you can have Filters and/or Servlets inspect the ServletContext attribute and take appropriate action, like displaying an error page.

提交回复
热议问题