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

Popular posts from this blog

swift - Button on Table View Cell connected to local function -

dns - Dokku server hosts two sites with TLD's, both domains are landing on only one app -

c# - ajax - How to receive data both html and json from server? -