Pages

Tuesday 12 August 2014

What is the web.xml file used for ?

Generally speaking, this is the configuration file of web applications in java. It instructs the servlet container (tomcat for ex.) which classes to load, what parameters to set in the context, and how to intercept requests coming from browsers.
There you specify:
  • what servlets (and filters) you want to use and what URLs you want to map them to
  • listeners - classes that are notified when some events happen (context starts, session created, etc)
  • configuration parameters (context-params)
  • error pages, welcome files
  • security constriants
In servlet 3.0 many of the web.xml parts are optional. These configurations can be done via annotations (@WebServlet@WebListener)

No comments:

Post a Comment