The web.xml file provides configuration and deployment information for the Web components that comprise a Web application. Examples of Web components are servlet parameters, servlet and JavaServer Pages (JSP) definitions, and Uniform Resource Locators (URL) mappings.
The servlet 2.3 specification dictates the format of the web.xml file, which makes this file portable among Java Two Enterprise Edition (J2EE) compliant products.
Location
The web.xml file must reside in the WEB-INF directory under the context of the hierarchy of directories that exist for a Web application. For example, if the application is client.war, then the web.xml file is placed in the install_root/client war/WEB-INF directory.
Usage notes
No
This file is updated by an assembly tool.
The assembly tool updates the web.xml file when you assemble Web components into a Web module, or when you modify the properties of the Web components or the Web module.
WebSphere Application Server functions use information in this file during the configuration and deployment phases of Web application development.
To use the isUserInRole method with JSP files, you must map a servlet to a specific JSP file name that uses the .jsp extension. Add the JSP file name to the <servlet>, <servlet-mapping>, and <web-resource-collection> sections of your web.xml file as shown in the following example:
<servlet> <servlet-name>SimpleFileReader</servlet-name> <display-name>SimpleFileReader</display-name> <jsp-file>/SimpleFileReader.jsp</jsp-file> <security-role-ref> <role-name>Manager</role-name> <role-link>Manager</role-link> </security-role-ref> </servlet>
<servlet-mapping> <servlet-name>SimpleFileReader</servlet-name> <url-pattern>/SimpleFileReader.jsp</url-pattern> </servlet-mapping>
<web-resource-collection> <web-resource-name>New Web resource collection</web-resource-name> <description></description> <url-pattern>/SimpleFileReaderServlet</url-pattern> <url-pattern>/SimpleFileReader.jsp</url-pattern> <http-method>GET</http-method> <http-method>PUT</http-method> <http-method>HEAD</http-method> <http-method>TRACE</http-method> <http-method>POST</http-method> <http-method>DELETE</http-method> <http-method>OPTIONS</http-method> </web-resource-collection>
Sample file entry
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc. //DTD Web Application 2.3//EN" "http://java.sun.com/j2ee/dtds/web-app_2_3.dtd"> <web-app id="WebApp_1"> <display-name>Persistence Manager Web Client</display-name> <description>Peristence Manager Web Client</description> <servlet id="Servlet_1"> <servlet-name>CustomerLocalServlet</servlet-name> <description>Local Customer Servlet</description> <servlet-class>CustomerLocalServlet</servlet-class> </servlet> <servlet id="Servlet_2"> <servlet-name>CustomerServlet</servlet-name> <description>Remote Customer Servlet</description> <servlet-class>CustomerServlet</servlet-class> </servlet> <servlet id="Servlet_3"> <servlet-name>CreditCardServlet</servlet-name> <description>Credit Card Servlet - PM Verification</description> <servlet-class>CreditCardServlet</servlet-class> </servlet> <servlet-mapping id="ServletMapping_1"> <servlet-name>CustomerLocalServlet</servlet-name> <url-pattern>/CustomerLocal</url-pattern> </servlet-mapping> <servlet-mapping id="ServletMapping_2"> <servlet-name>CustomerServlet</servlet-name> <url-pattern>/Customer</url-pattern> </servlet-mapping> <servlet-mapping id="ServletMapping_3"> <servlet-name>CreditCardServlet</servlet-name> <url-pattern>/CreditCard</url-pattern> </servlet-mapping> <welcome-file-list id="WelcomeFileList_1"> <welcome-file>index.html</welcome-file> </welcome-file-list> <security-role id="SecurityRole_1"> <description>Everyone role</description> <role-name>Everyone Role</role-name> </security-role> <security-role id="SecurityRole_2"> <description>AllAuthenticated role</description> <role-name>All Role</role-name> </security-role> <security-role id="SecurityRole_3"> <description>Deny all access role</description> <role-name>DenyAllRole</role-name> </security-role> </web-app>