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, application, application, asf, define, define, license, license, manager, manager, security, see, servlet, 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"> 

  <display-name>Tomcat Manager Application
  <description>
    A scriptable management web application for the Tomcat Web Server;
    Manager lets you view, load/unload/etc particular web applications.
  </description>

  <!-- Define the Manager Servlet
       Change servlet-class to: org.apache.catalina.servlets.HTMLManagerServlet
       to get a Servlet with a more intuitive HTML interface, don't change if you
       have software that is expected to parse the output from ManagerServlet
       since they're not compatible.
   -->
  <servlet>
    <servlet-name>Manager
    <servlet-class>org.apache.catalina.manager.ManagerServlet
    <init-param>
      <param-name>debug
      <param-value>2
    </init-param>
  </servlet>
  <servlet>
    <servlet-name>HTMLManager
    <servlet-class>org.apache.catalina.manager.HTMLManagerServlet
    <init-param>
      <param-name>debug
      <param-value>2
    </init-param>
  </servlet>
  <servlet>
    <servlet-name>Status
    <servlet-class>org.apache.catalina.manager.StatusManagerServlet
    <init-param>
      <param-name>debug
      <param-value>0
    </init-param>
  </servlet>

  <servlet>
    <servlet-name>JMXProxy
    <servlet-class>org.apache.catalina.manager.JMXProxyServlet
  </servlet>

  <!-- Define the Manager Servlet Mapping -->
  <servlet-mapping>
    <servlet-name>Manager
      <url-pattern>/list
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>Manager
      <url-pattern>/expire
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>Manager
      <url-pattern>/sessions
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>Manager
      <url-pattern>/start
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>Manager
      <url-pattern>/stop
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>Manager
      <url-pattern>/install
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>Manager
      <url-pattern>/remove
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>Manager
      <url-pattern>/deploy
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>Manager
      <url-pattern>/undeploy
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>Manager
      <url-pattern>/reload
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>Manager
      <url-pattern>/save
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>Manager
      <url-pattern>/serverinfo
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>Manager
      <url-pattern>/roles
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>Manager
      <url-pattern>/resources
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>Status
    <url-pattern>/status/*
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>JMXProxy
      <url-pattern>/jmxproxy/*
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>HTMLManager
    <url-pattern>/html/*
  </servlet-mapping>

  <!-- Define reference to the user database for looking up roles -->
  <resource-env-ref>
    <description>
      Link to the UserDatabase instance from which we request lists of
      defined role names.  Typically, this will be connected to the global
      user database with a ResourceLink element in server.xml or the context
      configuration file for the Manager web application.
    </description>
    <resource-env-ref-name>users
    <resource-env-ref-type>
      org.apache.catalina.UserDatabase
    </resource-env-ref-type>
  </resource-env-ref>

  <!-- Define a Security Constraint on this Application -->
  <security-constraint>
    <web-resource-collection>
      <web-resource-name>HTMLManger and Manager command
      <url-pattern>/jmxproxy/*
      <url-pattern>/html/*
      <url-pattern>/list
      <url-pattern>/expire
      <url-pattern>/sessions
      <url-pattern>/start
      <url-pattern>/stop
      <url-pattern>/install
      <url-pattern>/remove
      <url-pattern>/deploy
      <url-pattern>/undeploy
      <url-pattern>/reload
      <url-pattern>/save
      <url-pattern>/serverinfo
      <url-pattern>/status/*
      <url-pattern>/roles
      <url-pattern>/resources
    </web-resource-collection>
    <auth-constraint>
       <!-- NOTE:  This role is not present in the default users file -->
       <role-name>manager
    </auth-constraint>
  </security-constraint>

  <!-- Define the Login Configuration for this Application -->
  <login-config>
    <auth-method>BASIC
    <realm-name>Tomcat Manager Application
  </login-config>

  <!-- Security roles referenced by this web application -->
  <security-role>
    <description>
      The role that is required to log in to the Manager Application
    </description>
    <role-name>manager
  </security-role>

  <error-page>
    <error-code>401
    <location>/401.jsp
  </error-page>

</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.