General Settings
<description>A simple web application</description> <display-name>My first application</display-name> <icon> <small-icon>app-small.gif</small-icon> <!-- optional; GIF or JPEG --> <large-icon>app-large.gif</large-icon> <!-- optional; GIF or JPEG --> </icon>
Description Example
This is a simple web.xml containing only name, description and icon. Such a descriptor can be used for a WAR containing only JSPs or static content.
<?xml version="1.0" encoding="UTF-8"?> <web-app 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" version="2.4"> <description>A simple web application</description> <display-name>My first application</display-name> <icon> <small-icon>my-app-small.gif</small-icon> <large-icon>my-app-large.gif</large-icon> </icon> </web-app>
<mime-mapping> <!-- set MIME type for file extension --> <extension>txt</extension> <mime-type>plain/text</mime-type> </mime-mapping> <welcome-file-list> <!-- configure default file names --> <welcome-file>index.jsp</welcome-file> <welcome-file>index.html</welcome-file> <!-- more than one file name allowed --> </welcome-file-list> <error-page> <!-- configure error page for HTTP codes --> <error-code>404</error-code> <error-page>/error404.html</error-page> </error-page> <error-page> <!-- configure error page for exception --> <exception-type>java.lang.NullPointerException</exception-type> <error-page>/errorNPE.html</error-page> </error-page> <locale-encoding-mapping-list> <!-- assign character sets to locales --> <locale-encoding-mapping> <!-- one per locale --> <locale>ja</locale> <encoding>Shift_JIS</encoding> </locale-encoding-mapping> </locale-encoding-mapping-list>
Configuration Example
This is a web.xml with some random settings for static content.
<?xml version="1.0" encoding="UTF-8"?> <web-app 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" version="2.4"> <mime-mapping> <extension>jnlp</extension> <mime-type>application/x-java-jnlp-file</mime-type> </mime-mapping> <mime-mapping> <extension>xhtml</extension> <mime-type>application/xhtml+xml</mime-type> </mime-mapping> <welcome-file-list> <welcome-file>index.jspx</welcome-file> <welcome-file>index.jsp</welcome-file> <welcome-file>index.xhtml</welcome-file> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>default.htm</welcome-file> </welcome-file-list> <error-page> <error-code>404</error-code> <error-page>/error404.html</error-page> </error-page> <error-page> <error-code>500</error-code> <error-page>/generic-sorry.html</error-page> </error-page> <error-page> <exception-type>java.lang.NullPointerException</exception-type> <error-page>/stupidbug.html</error-page> </error-page> <locale-encoding-mapping-list> <locale-encoding-mapping> <locale>de</locale> <encoding>UTF-8</encoding> </locale-encoding-mapping> <locale-encoding-mapping> <locale>fr</locale> <encoding>UTF-8</encoding> </locale-encoding-mapping> <locale-encoding-mapping> <locale>es</locale> <encoding>UTF-8</encoding> </locale-encoding-mapping> </locale-encoding-mapping-list> </web-app>
<context-param> <!-- for ServletConfig.getInitParameter. One per parameter. --> <description>the webmaster's name</description> <!-- optional --> <param-name>myWebmastersName</param-name> <!-- any unique name is allowed --> <param-value>Tom</param-value> </context-param> <session-config> <!-- configure sessions --> <session-timeout>5</session-timeout> <!-- optional; timeout in minutes --> </session-config> <jsp-config> <!-- configuration for JSPs --> <taglib> <!-- repeat for each taglib --> <taglib-uri>http://taglibs.jarfiller.com/myLib</taglib-uri> <taglib-location>/WEB-INF/jftaglib/jg.tld</taglib-location> </taglib> <jsp-property-group> <!-- settings for a group of JSPs --> <url-pattern>*.jsp</url-pattern> <!-- for all *.jsp files --> <url-pattern>*.view</url-pattern> <!-- more than one pattern allowed --> <el-ignored>false</el-ignored> <!-- optional --> <page-encoding>UTF-8</page-encoding> <!-- optional --> <scripting-invalid>false</scripting-invalid> <!-- optional --> <is-xml>false</is-xml> <!-- optional --> <include-prelude>/WEB-INF/fragments/header.jspf</include-prelude> <!-- optional --> <include-coda>/WEB-INF/fragments/footer.jspf</include-coda> <!-- optional --> </jsp-property-group> </jsp-config> <distributable /> <!-- set if application is distributable -->
Configuration Example
This is a web.xml with some random settings for dynamic content.
<?xml version="1.0" encoding="UTF-8"?> <web-app 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" version="2.4"> <context-param> <param-name>appName</param-name> <param-value>Example.com</param-value> </context-param> <context-param> <param-name>userThreshold</param-name> <param-value>20</param-value> </context-param> <session-config> <session-timeout>15</session-timeout> </session-config> <jsp-config> <taglib> <taglib-uri>http://taglibs.jarfiller.com/popupLib</taglib-uri> <taglib-location>/WEB-INF/popup.tld</taglib-location> </taglib> <jsp-property-group> <url-pattern>*.jsp</url-pattern> <page-encoding>UTF-8</page-encoding> <is-xml>true</is-xml> <include-coda>/WEB-INF/fragments/footer.jspf</include-coda> </jsp-property-group> </jsp-config> </web-app>

