Tomcat web.xml file in the details

sponsored links
Tomcat web.xml file in the details
<? Xml version = "1.0" encoding = "GB2312"?> <! -
Web.xml be meeting the following elements in order:
<display-name> </ display-name> defines the name of WEB applications
<description> </ description> Statement WEB application descriptions
<filter> </ filter>
<filter-mapping> </ filter-mapping>
<servlet> </ servlet>
<servlet-mapping> </ servlet-mapping>
<session-config> </ session-config>
<welcome-file-list> </ welcome-file-list>
<taglib> </ taglib>
<resource-ref> </ resource-ref>
<security-constraint> </ security-constraint>
<login-config> </ login-config>
</ Web-app>
Elements defined in web.xml can not reverse the order, or Tomcat server may throw SAXParseException.
<! DOCTYPE web-app PUBLIC "- / / Sun Microsystems, Inc. / / DTD Web Application 2.3 / / EN" "">

<display-name> Sample Application </ display-name>

This is a Sample Application
</ Description>

<! -
Servlet filters Configuring filter
filter filter-name defines the name. When there are multiple filters, you can not with the same name
filter-class designated to achieve this filter class that is responsible for specific filtering services
<filter-name> SampleFilter </ filter-name>
<filter-class> mypack.SampleFilter </ filter-class>
</ Filter>

<! -
filter filter-mapping configuration for URL filtering
filter filter-name name. The name here must be and filter in the filter names match
url-pattern filter for filtering the specified URL
<filter-name> SampleFilter </ filter-name>
<url-pattern> *. jsp </ url-pattern>
</ Filter-mapping>

<! -
servlet configuration Servlet.
Servlet servlet-name defines the name of
servlet-class specifies the class to achieve this servlet
Servlet init-param defines the initialization parameters and parameter values, can have more than one init-param. In the servlet class through getInitParamenter (String name) method to access initialization parameters
load-on-startup specified when the Web application starts, Servlet load order.
When the value is positive or zero: Servlet container load values smaller first servlet, and then in turn load other numerical big servlet.
When the value is negative or undefined: Servlet container will first visit the Web client when it is loaded servlet
<servlet-name> SampleServlet </ servlet-name>
<servlet-class> mypack.SampleServlet </ servlet-class>
<param-name> initParam1 </ param-name>
<param-value> 2 </ param-value>
</ Init-param>
<load-on-startup> 1 </ load-on-startup>
</ Servlet>

<! -
Configure servlet mapping (following code SampleServlet specified relative URL for the "/ sample":
servlet servlet-name specifies the name, where name should be defined and <Servlet> element name matching.
url-pattern specified to access this servlet's URL. Just give a relative path.
<servlet-name> SampleServlet </ servlet-name>
<url-pattern> / sample </ url-pattern>
</ Servlet-mapping>

<! - Configuration session session used to set the HttpSession of the life cycle. Unit (sub) ->
<session-timeout> 30 </ session-timeout>
</ Session-config>

<! - Configuration Wel0come0 file list ->
<welcome-file> login.jsp </ welcome-file>
<welcome-file> index.htm </ welcome-file>
</ Welcome-file-list>

<! -
Configuration Tag Library
Set Tag Library taglib-uri unique identifier, in the Web application will be the basis of this identifier to reference Tag Library
taglib-location specified and the corresponding TLD files Tag Library location
<taglib-uri> / mytaglib </ taglib-uri>
<taglib-location> / WEB-INF/mytaglib.tld </ taglib-location>
</ Taglib>

<! -
Allocation of resources referenced
description of the resources cited in note
res-ref-name specifies the JNDI name reference resources
res-type referenced by the specified resource class name
res-auth designated reference resource management Manager, it has two optional values:
Container: the container to create and manage resource
Application: Application with WEB to create and manage Resource
<description> DB Connection </ description>
<res-ref-name> jdbc / sampleDB </ res-ref-name>
<res-type> javax.sql.DataSource </ res-type>
<res-auth> Container </ res-auth>
</ Resource-ref>

<! -
Configuring security constraints (the following code to specify the application when the user access to the WEB all the resources under, must have guest role)
web-resource-collection statement protected WEB resources
auth-constraint statement can access the protected resources, the role of sub-elements can contain multiple <role-name>

web-resource-name identity protected WEB resources
url-pattern specified by the URL path protection
<web-resource-name> sample appliction </ web-resource-name>
<url-pattern> / * </ url-pattern>
</ Web-resource-collection>
<role-name> guest </ role-name>
</ Auth-constraint>
</ Security-constraint>

<! -
Configure security authentication login screen: Specifies when the WEB WEB client access a protected resource, the system logon dialog box that pops up type.
auth-method specified authentication method, which has three optional values: BASIC (basic authentication), DIGEST (digest authentication), FORM (Forms Authentication)
realm-name set the security domain name
form-login-config when the authentication method is FORM, the configuration verification page and error page
form-login-page when the authentication method is FORM, set the authentication page
form-error-page when the authentication method is FORM, set the error page
<auth-method> FORM </ auth-method>
Tomcat Server Configuration form-Based Authentication Area
</ Realm-name>
<form-login-page> / login.jsp </ form-login-page>
<form-error-page> / error.jsp </ form-error-page>
</ Form-login-config>
</ Login-config>

<! - Configure role references to security verification ->
The role that is required to log into the sample application
</ Description>
<role-name> guest </ role-name>
</ Security-role>
</ Web-app>
  • StumbleUpon
  • Digg
  • TwitThis
  • Mixx
  • Technorati
  • Facebook
  • NewsVine
  • Reddit
  • Google
  • LinkedIn
  • YahooMyWeb

Related Posts of Tomcat web.xml file in the details

  • Process migration from tomcat to websphere changes

    Process migration from tomcat to websphere changes Because customers use the web application server software used by different what tomcat5, tomcat6, websphere5.1, websphere6.1, weblogic8, and so on, and the software used inconsistent standards, ibm's


    dsfdsa Tomcat 6 with the connection pool data source configuration project: test Driver path: D: \ workspace \ test \ WebRoot \ WEB-INF \ lib ...

  • Hibernate.cfg.xml configuration file (including the primary key generation strategy Introduction)

    Hibernate.cfg.xml configuration file: <? xml version = "1.0" encoding = "utf-8"?> <! DOCTYPE hibernate-configuration PUBLIC "- / / Hibernate / Hibernate Configuration DTD / / EN" "hibernate-configuration-2.0.dtd

  • The EJB3 Persistence

    EJB3 persistence with Hibernate is very similar to the mechanism: Environment: Server: JBOSS5.0 Database: MySQL5.0 1. Set up a data source First of all, in jboss-5.0.0.GA \ server \ default \ deploy, the establishment of a database used to connect the dat

  • Servlet brief introduction

    Servlet brief introduction: Servlet is a small application server Are used to complete the B / S architecture, the client requests the response to treatment Platform independence, performance, able to run thread Servlet API for Servlet provides the s ...

  • Spring2.0 + hibernate3.1 + log4j + mysql demo

    applicationContext.xml Non-attachment jar package, necessary friends can send an email to todd.liangt @

blog comments powered by Disqus
Recent Entries
Tag Cloud
Random Entries