alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Tomcat example source code file (web.xml)

This example Tomcat source code file (web.xml) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Tomcat tags/keywords

apache, character, define, define, encoding, filter, filter, jsp, license, license, mapped, mapped, see, you

The Tomcat web.xml source code

<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
 Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->

<web-app xmlns="http://java.sun.com/xml/ns/javaee"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
   version="2.5"> 

    <description>
      Servlet and JSP Examples.
    </description>
    <display-name>Servlet and JSP Examples


    <!-- Define servlet-mapped and path-mapped example filters -->
    <filter>
        <filter-name>Servlet Mapped Filter
        <filter-class>filters.ExampleFilter
	<init-param>
	    <param-name>attribute
	    <param-value>filters.ExampleFilter.SERVLET_MAPPED
	</init-param>
    </filter>
    <filter>
        <filter-name>Path Mapped Filter
        <filter-class>filters.ExampleFilter
	<init-param>
	    <param-name>attribute
	    <param-value>filters.ExampleFilter.PATH_MAPPED
	</init-param>
    </filter>
    <filter>
        <filter-name>Request Dumper Filter
        <filter-class>filters.RequestDumperFilter
    </filter>

    <!-- Example filter to set character encoding on each request -->
    <filter>
        <filter-name>Set Character Encoding
        <filter-class>filters.SetCharacterEncodingFilter
        <init-param>
            <param-name>encoding
            <param-value>EUC_JP
        </init-param>
    </filter>

    <filter>
        <filter-name>Compression Filter
        <filter-class>compressionFilters.CompressionFilter

        <init-param>
          <param-name>compressionThreshold
          <param-value>10
        </init-param>
        <init-param>
          <param-name>debug
          <param-value>0
        </init-param>
    </filter>

    <!-- Define filter mappings for the defined filters -->
    <filter-mapping>
        <filter-name>Servlet Mapped Filter
	<servlet-name>invoker
    </filter-mapping>
    <filter-mapping>
        <filter-name>Path Mapped Filter
	<url-pattern>/servlet/*
    </filter-mapping>

<!-- Example filter mapping to apply the "Set Character Encoding" filter
     to *all* requests processed by this web application -->
<!--
    <filter-mapping>
        <filter-name>Set Character Encoding
        <url-pattern>/*
    </filter-mapping>
-->

<!--
    <filter-mapping>
      <filter-name>Compression Filter
      <url-pattern>/CompressionTest
    </filter-mapping>
-->

<!--
    <filter-mapping>
        <filter-name>Request Dumper Filter
        <url-pattern>/*
    </filter-mapping>
-->

    <!-- Define example application events listeners -->
    <listener>
        <listener-class>listeners.ContextListener
    </listener>
    <listener>
        <listener-class>listeners.SessionListener
    </listener>

    <!-- Define servlets that are included in the example application -->

    <servlet>
      <servlet-name>servletToJsp
      <servlet-class>servletToJsp
    </servlet>
    <servlet>
        <servlet-name>ChatServlet
        <servlet-class>chat.ChatServlet
    </servlet>
    <servlet>
        <servlet-name>CompressionFilterTestServlet
        <servlet-class>compressionFilters.CompressionFilterTestServlet
    </servlet>
    <servlet>
        <servlet-name>HelloWorldExample
        <servlet-class>HelloWorldExample
    </servlet>
    <servlet>
        <servlet-name>RequestInfoExample
        <servlet-class>RequestInfoExample
    </servlet>
    <servlet>
        <servlet-name>RequestHeaderExample
        <servlet-class>RequestHeaderExample
    </servlet>
    <servlet>
        <servlet-name>RequestParamExample
        <servlet-class>RequestParamExample
    </servlet>
    <servlet>
        <servlet-name>CookieExample
        <servlet-class>CookieExample
    </servlet>
    <servlet>
        <servlet-name>SessionExample
        <servlet-class>SessionExample
    </servlet>

    <servlet-mapping>
        <servlet-name>ChatServlet
        <url-pattern>/jsp/chat/chat
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>CompressionFilterTestServlet
        <url-pattern>/CompressionTest
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>HelloWorldExample
        <url-pattern>/servlets/servlet/HelloWorldExample
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>RequestInfoExample
        <url-pattern>/servlets/servlet/RequestInfoExample/*
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>RequestHeaderExample
        <url-pattern>/servlets/servlet/RequestHeaderExample
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>RequestParamExample
        <url-pattern>/servlets/servlet/RequestParamExample
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>CookieExample
        <url-pattern>/servlets/servlet/CookieExample
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>SessionExample
        <url-pattern>/servlets/servlet/SessionExample
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>servletToJsp
        <url-pattern>/servletToJsp
    </servlet-mapping>

    <jsp-config>
        <taglib>
	    <taglib-uri>
	       http://jakarta.apache.org/tomcat/debug-taglib
	    </taglib-uri>
	    <taglib-location>
	       /WEB-INF/jsp/debug-taglib.tld
	    </taglib-location>
	</taglib>

	<taglib>
	    <taglib-uri>
	       http://jakarta.apache.org/tomcat/examples-taglib
	    </taglib-uri>
	    <taglib-location>
	       /WEB-INF/jsp/example-taglib.tld
	    </taglib-location>
	</taglib>

	<taglib>
	    <taglib-uri>
	       http://jakarta.apache.org/tomcat/jsp2-example-taglib
	    </taglib-uri>
	    <taglib-location>
	       /WEB-INF/jsp2/jsp2-example-taglib.tld
	    </taglib-location>
	</taglib>

	<jsp-property-group>
	    <description>
		Special property group for JSP Configuration JSP example.
	    </description>
	    <display-name>JSPConfiguration
	    <url-pattern>/jsp2/misc/config.jsp
	    <el-ignored>true
	    <page-encoding>ISO-8859-1
	    <scripting-invalid>true
	    <include-prelude>/jsp2/misc/prelude.jspf
	    <include-coda>/jsp2/misc/coda.jspf
	</jsp-property-group>
    </jsp-config>
    
   <security-constraint>
      <display-name>Example Security Constraint
      <web-resource-collection>
         <web-resource-name>Protected Area
	 <!-- Define the context-relative URL(s) to be protected -->
         <url-pattern>/jsp/security/protected/*
	 <!-- If you list http methods, only those methods are protected -->
	 <http-method>DELETE
         <http-method>GET
         <http-method>POST
	 <http-method>PUT
      </web-resource-collection>
      <auth-constraint>
         <!-- Anyone with one of the listed roles may access this area -->
         <role-name>tomcat
	 <role-name>role1
      </auth-constraint>
    </security-constraint>

    <!-- Default login configuration uses form-based authentication -->
    <login-config>
      <auth-method>FORM
      <realm-name>Example Form-Based Authentication Area
      <form-login-config>
        <form-login-page>/jsp/security/protected/login.jsp
        <form-error-page>/jsp/security/protected/error.jsp
      </form-login-config>
    </login-config>
        
    <!-- Security roles referenced by this web application -->
    <security-role>
      <role-name>role1
    </security-role>
    <security-role>
      <role-name>tomcat
    </security-role>    

    <!-- Environment entry examples -->
    <!--env-entry>
      <env-entry-description>
         The maximum number of tax exemptions allowed to be set.
      </env-entry-description>
      <env-entry-name>maxExemptions
      <env-entry-type>java.lang.Integer
      <env-entry-value>15
    </env-entry-->
    <env-entry>
      <env-entry-name>minExemptions
      <env-entry-type>java.lang.Integer
      <env-entry-value>1
    </env-entry>
    <env-entry>
      <env-entry-name>foo/name1
      <env-entry-type>java.lang.String
      <env-entry-value>value1
    </env-entry>
    <env-entry>
      <env-entry-name>foo/bar/name2
      <env-entry-type>java.lang.Boolean
      <env-entry-value>true
    </env-entry>
    <env-entry>
      <env-entry-name>name3
      <env-entry-type>java.lang.Integer
      <env-entry-value>1
    </env-entry>
    <env-entry>
      <env-entry-name>foo/name4
      <env-entry-type>java.lang.Integer
      <env-entry-value>10
    </env-entry>

</web-app>

Other Tomcat examples (source code examples)

Here is a short list of links related to this Tomcat web.xml source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.