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 人气:474
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 co

  • 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, knowle

  • maven警告:com.sun.image.codec.jpeg.JPEGCodec 是 Sun 的 2014-03-26

    警告:com.sun.image.codec.jpeg.JPEGCodec 是 Sun 的专用 API,可能会在未来版本中删除 解决办法 在pom.xml中bulid -> publgins加入: <plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration> <encoding>UTF-8</encoding> <compilerArgume

  • 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 dow

  • 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

  • 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 releva

  • Java 学习杂谈(八):Servlet/Jsp 2015-04-20


  • 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 \

  • Found during the use of it for the MyEclipse Java code for the failure of the auto-suggest, and for normal JSP was able to give prompt 2010-09-28

    Found during the use of it for the MyEclipse Java code for the failure of the auto-suggest, and for normal JSP was able to give tips. After a lot of Baidu Internet to find a solution, but because of different reasons for this phenomenon, so basically

  • Java based - Xin Sun Java Chinese garbled about the cause of the problem (b) 2010-12-04

    Java based - Xin Sun Java Chinese garbled about the cause of (b) On: Sun Xin Source: Sun Xin Publisher: admin Time :2009-07-22 10:56:59 Views: 2734 Characters and strings in the output when encoding from Unicode to the default encoding GBK Chinese sy

iOS 开发

Android 开发

Python 开发



PHP 开发

Ruby 开发






Javascript 开发

.NET 开发



Copyright (C), All Rights Reserved. 版权所有 闽ICP备15018612号

processed in 0.036 (s). 13 q(s)