Tomcat web.xml file in the details

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>

分类:Java 时间:2010-03-29 人气:406
blog comments powered by Disqus


  • web.xml java web project, something a little 2010-12-03

    A web in the web.xml file can not, that is, web.xml files are not web projects necessary. That when they need, when you can not it? To answer the above questions, you must first understand the web.xml file to use to do the. web.xml file is used to configu

  • Parsing XML, JAVA comparison of four methods 2010-07-19

    JAVA XML parsing XML Comparison of four has now become a common data exchange format, it's platform Wu Guan, language independence, Ji Tong independence, Ji Ji Cheng and Jiaohu data has brought great convenience. The syntax for the XML itself, kn

  • Jump to, sun site logo change 2010-03-29

    This Address: Today, ready to download the latest version of the jdk, we found that sun site logo has been replaced by oracle, color style consistent with the oracle. jdk download

  • java study notes 8 Servlet / Jsp 2010-10-28

    J2ee finally officially entered the details of the, of course, bear the brunt of the Servlet and Jsp, J2ee on the articles have mentioned only a specification and guidelines, define a set of interfaces must be followed, the core concept of components and

  • Java problems in Chinese mysql, oracle, servlet, jsp 2009-10-06

    [url] [/ url] Java problems in Chinese mysql, oracle, servlet, jsp Copyright: CSDN is Blog hosting service provider. In this paper, such as copyright issues involved, CSDN not bear the relevant re

  • Web Summary --- Servlet, JSP, filters and listeners, the scope and nine four built-in objects, EL expression language, custom tags, JSTL, an international collection of the Chinese character encoding 2011-01-01

    1, Servlet, ServletConfig: The former corresponds to a Servlet class, which corresponds to the configuration information in the web.xml (1) Servlet: init (ServletConfig): only then loaded and instantiated class is called once. service (ServletRequest, Ser

  • javax.servlet.ServletException: java.lang.NoSuchMethodError: javax.servlet.jsp.J 2009-08-13

    javax.servlet.ServletException: java.lang.NoSuchMethodError: javax.servlet.jsp.JspFactory.getJspApplicationContext (Ljavax / servlet / ServletContext;) Ljavax / servlet / jsp / JspApplicationContext The problem occurs because of WEB project WEB-INF \ lib

  • J2ME dear compatriots, my team has developed an application, specially brought a sun 2010-11-12

    Our Website: I firmly believe, J2ME is very promising, but, I now lead the team development android android version of the sun a few pictures, not scolded best. . . . Welcome to the criticism, but try not to burst dirty mouth, I d

  • Four methods of parsing XML, Java [change] 2010-09-08

    XML has now become a common data exchange format, it's platform-independent, language independence, system independence, to the data of Ji Tai Ji Cheng and Jiaohudailai convenience. The syntax for the XML itself, knowledge and technical details,

  • Four methods of parsing XML, Java 2011-04-25

    XML has now become a common data exchange format, and its platform independence, language independence, system independence, data integration and interaction to bring great convenience. For the syntax of XML itself, knowledge and technical details, y

iOS 开发

Android 开发

Python 开发



PHP 开发

Ruby 开发






Javascript 开发

.NET 开发



Copyright (C), All Rights Reserved. 版权所有 黔ICP备15002463号-1

processed in 0.276 (s). 14 q(s)