René Nyffenegger's collection of things on the web
René Nyffenegger on Oracle - Most wanted - Feedback -


The web.xml file defines each servlet and JSP page within a Web Application. It also enumerates enterprise beans referenced in the Web application.
The file goes into the WEB-INF directory under the document root of a web application.

A sample web.xml

This xml file is alls called deployment descriptor.
<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app 
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" 


      The name of the application 
      C'mon, you know what goes into a description, don't you?

      <description> Again, some description </description>

      <description>Again, some description</description>






The values within the context-param element can be accessed like so:
String value = getServletContext().getInitParameter("name_of_context_initialization_parameter");
Servlet initialization parameters (that is: the values within the servlet element) can be retrieved in a servlet or JSP page by calling:
String value = getServletConfig().getInitParameter("foo");


<session-timeout>: The timeout for a session in minutes.


For each servlet in the web application, there is a <servlet> element. The name identifies the servlet (<servlet-name>).


Each servlet in the web application gets a servlet mapping. The url pattern is used to map URI to servlets.
Obviously, the order of the elements matters!