WebSphere Application Server Version 6.1 Feature Pack for Web Services
             Operating Systems: AIX, HP-UX, i5/OS, Linux, Solaris, Windows, z/OS

             Personalize the table of contents and search results

web.xml file

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 Java Servlet 2.4 specification defines the web.xml deployment descriptor file in terms of an XML schema document. For backwards compatibility of applications written to the Java Servlet 2.2 Specification, Web containers are also required to support the Java Servlet 2.2 specification. For backwards compatibility of applications written to the Java Servlet 2.3 specification, Web containers are also required to support the Java Servlet 2.3 specification.

If you use Rational Application Developer version 6 to create your portlets, you must remove the following reference to the std-portlet.tld from the web.xml file:
<taglib id="PortletTLD">
			<taglib-uri>http://java.sun.com/portlet</taglib-uri>
			<taglib-location>/WEB-INF/tld/std-portlet.tld</taglib-location>
		</taglib>

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.

[AIX HP-UX Linux Solaris Windows] [z/OS] For example, if the application is client.war, then the web.xml file is placed in the install_root/client war/WEB-INF directory.

[i5/OS] For example, if the application is client.war, then the web.xml file is placed in the profile_root/installedApps/cellName/client.ear/client.war/WEB-INF directory (in a default installation), where the edition is either Base or ND depending on which edition you are using.

Usage notes

Sample file entry

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_9" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" 
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
	xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
	<display-name>Servlet 2.4 application</display-name>
	<filter>
		<filter-name>ServletMappedDoFilter_Filter</filter-name>
		<filter-class>tests.Filter.DoFilter_Filter</filter-class>
		<init-param>
			<param-name>attribute</param-name>
			<param-value>tests.Filter.DoFilter_Filter.SERVLET_MAPPED</param-value>
			</init-param>
	</filter>
	<filter-mapping>
		<filter-name>ServletMappedDoFilter_Filter</filter-name>
		<url-pattern>/DoFilterTest</url-pattern>
		<dispatcher>REQUEST</dispatcher>
	</filter-mapping>
	<filter-mapping>
		<filter-name>ServletMappedDoFilter_Filter</filter-name>
		<url-pattern>/IncludedServlet</url-pattern>
		<dispatcher>INCLUDE</dispatcher>
	</filter-mapping>
	<filter-mapping>
		<filter-name>ServletMappedDoFilter_Filter</filter-name>
		<url-pattern>ForwardedServlet</url-pattern>
		<dispatcher>FORWARD</dispatcher>
	</filter-mapping>
	<listener>
		<listener-class>tests.ContextListener</listener-class>
	</listener>
	<listener>
		<listener-class>tests.ServletRequestListener.RequestListener</listener-class>
	</listener>
	<servlet>
		<servlet-name>welcome</servlet-name>
		<servlet-class>WelcomeServlet</servlet-class>
	</servlet>
	<servlet>
		<servlet-name>ServletErrorPage</servlet-name>
		<servlet-class>tests.Error.ServletErrorPage</servlet-class>
	</servlet>
	<servlet>
		<servlet-name>IncludedServlet</servlet-name>
		<servlet-class>tests.Filter.IncludedServlet</servlet-class>
	</servlet>
	<servlet>
		<servlet-name>ForwardedServlet</servlet-name>
		<servlet-class>tests.Filter.ForwardedServlet</servlet-class>
	</servlet>
	<servlet-mapping>
		<servlet-name>welcome</servlet-name>
		<url-pattern>/hello.welcome</url-pattern>
	</servlet-mapping>
	<servlet-mapping>
		<servlet-name>ServletErrorPage</servlet-name>
		<url-pattern>/ServletErrorPage</url-pattern>
	</servlet-mapping>
	<servlet-mapping>
		<servlet-name>IncludedServlet</servlet-name>
		<url-pattern>/IncludedServlet</url-pattern>
	</servlet-mapping>
	<servlet-mapping>
		<servlet-name>ForwardedServlet</servlet-name>
		<url-pattern>/ForwardedServlet</url-pattern>
	</servlet-mapping>
	<welcome-file-list>
		<welcome-file>hello.welcome</welcome-file>
	</welcome-file-list>
	<error-page>
		<exception-type>java.lang.ArrayIndexOutOfBoundsException</exception-type>
		<location>/ServletErrorPage</location>
	</error-page>
</web-app>
	



Related concepts
Web applications
Web modules
Assembly tools
Related tasks
Viewing deployment descriptors
Related reference
Web applications: Resources for learning
Related information
Servlets
Reference topic    

Terms of Use | Feedback

Last updated: Nov 25, 2008 2:35:59 AM CST
http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=/com.ibm.websphere.wsfep.multiplatform.doc/info/ae/ae/rweb_webxf.html