jsp - Handle ServletException - Java Servlet API 3.+ -
i understand handling servletexception web-inf/web.xml file using <error-page> tag:
<error-page> <error-code>500</error-code> <location>/error.jsp</location> </error-page> i've read several times, should avoid using web-inf/web.xml file in combination java servlet api 3.+.
how handle servletexceptions without web-inf/web.xml?
you read/understood wrong. not free want , work, can't entirely avoid using web.xml anyway - in case.
the heart of matter modern servlet specifications have useful annotations @webservlet, @webfilter , @weblistener make unnecessary declare such things servlets, filters , listeners inside web.xml saving bit of redundant xml configuration annoyance. particularly useful web frameworks , libraries can make things deploy automatically without having define in web.xml first.
if want use own servlets still you, might argue having configured in web.xml gives 1 place can lookup configuration rather having scout in several java source files.
there benefit still declaring things filters in web.xml: can force specific order of execution since executed in order appear in web.xml.
so no, not avoid web.xml as possible. avoid when makes sense.
Comments
Post a Comment