![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
1 <?xml version="1.0" encoding="ISO-8859-1"?> 2 <!-- 3 Licensed to the Apache Software Foundation (ASF) under one or more 4 contributor license agreements. See the NOTICE file distributed with 5 this work for additional information regarding copyright ownership. 6 The ASF licenses this file to You under the Apache License, Version 2.0 7 (the "License"); you may not use this file except in compliance with 8 the License. You may obtain a copy of the License at 9 10 http://www.apache.org/licenses/LICENSE-2.0 11 12 Unless required by applicable law or agreed to in writing, software 13 distributed under the License is distributed on an "AS IS" BASIS, 14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 See the License for the specific language governing permissions and 16 limitations under the License. 17 --> 18 <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" 19 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 20 xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee 21 http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" 22 version="3.1" 23 metadata-complete="true"> 24 25 <description> 26 Servlet and JSP Examples. 27 </description> 28 <display-name>Servlet and JSP Examples</display-name> 29 30 <!-- Define example filters --> 31 <filter> 32 <filter-name>Timing filter</filter-name> 33 <filter-class>filters.ExampleFilter</filter-class> 34 <init-param> 35 <param-name>attribute</param-name> 36 <param-value>filters.ExampleFilter</param-value> 37 </init-param> 38 </filter> 39 40 <filter> 41 <filter-name>Request Dumper Filter</filter-name> 42 <filter-class>org.apache.catalina.filters.RequestDumperFilter</filter-class> 43 </filter> 44 45 <!-- Example filter to set character encoding on each request --> 46 <filter> 47 <filter-name>Set Character Encoding</filter-name> 48 <filter-class>org.apache.catalina.filters.SetCharacterEncodingFilter</filter-class> 49 <async-supported>true</async-supported> 50 <init-param> 51 <param-name>encoding</param-name> 52 <param-value>UTF-8</param-value> 53 </init-param> 54 <init-param> 55 <param-name>ignore</param-name> 56 <param-value>false</param-value> 57 </init-param> 58 </filter> 59 60 <filter> 61 <filter-name>Compression Filter</filter-name> 62 <filter-class>compressionFilters.CompressionFilter</filter-class> 63 <init-param> 64 <param-name>compressionThreshold</param-name> 65 <param-value>128</param-value> 66 </init-param> 67 <init-param> 68 <param-name>compressionBuffer</param-name> 69 <param-value>8192</param-value> 70 </init-param> 71 <init-param> 72 <param-name>compressionMimeTypes</param-name> 73 <param-value>text/html,text/plain,text/xml</param-value> 74 </init-param> 75 <init-param> 76 <param-name>debug</param-name> 77 <param-value>0</param-value> 78 </init-param> 79 </filter> 80 81 <!-- Define filter mappings for the timing filters --> 82 <!-- 83 <filter-mapping> 84 <filter-name>Timing Filter</filter-name> 85 <url-pattern>/*</url-pattern> 86 </filter-mapping> 87 --> 88 89 <!-- Example filter mapping to apply the "Set Character Encoding" filter 90 to *all* requests processed by this web application --> 91 <filter-mapping> 92 <filter-name>Set Character Encoding</filter-name> 93 <url-pattern>/*</url-pattern> 94 </filter-mapping> 95 96 <!-- 97 <filter-mapping> 98 <filter-name>Compression Filter</filter-name> 99 <url-pattern>/CompressionTest</url-pattern> 100 </filter-mapping> 101 --> 102 103 <!-- 104 <filter-mapping> 105 <filter-name>Request Dumper Filter</filter-name> 106 <url-pattern>/*</url-pattern> 107 </filter-mapping> 108 --> 109 110 <!-- Define example application events listeners --> 111 <listener> 112 <listener-class>listeners.ContextListener</listener-class> 113 </listener> 114 <listener> 115 <listener-class>listeners.SessionListener</listener-class> 116 </listener> 117 118 <!-- Define servlets that are included in the example application --> 119 120 <servlet> 121 <servlet-name>ServletToJsp</servlet-name> 122 <servlet-class>ServletToJsp</servlet-class> 123 </servlet> 124 <servlet> 125 <servlet-name>ChatServlet</servlet-name> 126 <servlet-class>chat.ChatServlet</servlet-class> 127 </servlet> 128 <servlet> 129 <servlet-name>CompressionFilterTestServlet</servlet-name> 130 <servlet-class>compressionFilters.CompressionFilterTestServlet</servlet-class> 131 </servlet> 132 <servlet> 133 <servlet-name>HelloWorldExample</servlet-name> 134 <servlet-class>HelloWorldExample</servlet-class> 135 </servlet> 136 <servlet> 137 <servlet-name>RequestInfoExample</servlet-name> 138 <servlet-class>RequestInfoExample</servlet-class> 139 </servlet> 140 <servlet> 141 <servlet-name>RequestHeaderExample</servlet-name> 142 <servlet-class>RequestHeaderExample</servlet-class> 143 </servlet> 144 <servlet> 145 <servlet-name>RequestParamExample</servlet-name> 146 <servlet-class>RequestParamExample</servlet-class> 147 </servlet> 148 <servlet> 149 <servlet-name>CookieExample</servlet-name> 150 <servlet-class>CookieExample</servlet-class> 151 </servlet> 152 <servlet> 153 <servlet-name>SessionExample</servlet-name> 154 <servlet-class>SessionExample</servlet-class> 155 </servlet> 156 157 <servlet-mapping> 158 <servlet-name>ChatServlet</servlet-name> 159 <url-pattern>/servlets/chat/chat</url-pattern> 160 </servlet-mapping> 161 <servlet-mapping> 162 <servlet-name>CompressionFilterTestServlet</servlet-name> 163 <url-pattern>/CompressionTest</url-pattern> 164 </servlet-mapping> 165 <servlet-mapping> 166 <servlet-name>HelloWorldExample</servlet-name> 167 <url-pattern>/servlets/servlet/HelloWorldExample</url-pattern> 168 </servlet-mapping> 169 <servlet-mapping> 170 <servlet-name>RequestInfoExample</servlet-name> 171 <url-pattern>/servlets/servlet/RequestInfoExample/*</url-pattern> 172 </servlet-mapping> 173 <servlet-mapping> 174 <servlet-name>RequestHeaderExample</servlet-name> 175 <url-pattern>/servlets/servlet/RequestHeaderExample</url-pattern> 176 </servlet-mapping> 177 <servlet-mapping> 178 <servlet-name>RequestParamExample</servlet-name> 179 <url-pattern>/servlets/servlet/RequestParamExample</url-pattern> 180 </servlet-mapping> 181 <servlet-mapping> 182 <servlet-name>CookieExample</servlet-name> 183 <url-pattern>/servlets/servlet/CookieExample</url-pattern> 184 </servlet-mapping> 185 <servlet-mapping> 186 <servlet-name>SessionExample</servlet-name> 187 <url-pattern>/servlets/servlet/SessionExample</url-pattern> 188 </servlet-mapping> 189 <servlet-mapping> 190 <servlet-name>ServletToJsp</servlet-name> 191 <url-pattern>/servletToJsp</url-pattern> 192 </servlet-mapping> 193 194 <jsp-config> 195 <taglib> 196 <taglib-uri> 197 http://tomcat.apache.org/debug-taglib 198 </taglib-uri> 199 <taglib-location> 200 /WEB-INF/jsp/debug-taglib.tld 201 </taglib-location> 202 </taglib> 203 204 <taglib> 205 <taglib-uri> 206 http://tomcat.apache.org/example-taglib 207 </taglib-uri> 208 <taglib-location> 209 /WEB-INF/jsp/example-taglib.tld 210 </taglib-location> 211 </taglib> 212 213 <taglib> 214 <taglib-uri> 215 http://tomcat.apache.org/jsp2-example-taglib 216 </taglib-uri> 217 <taglib-location> 218 /WEB-INF/jsp2/jsp2-example-taglib.tld 219 </taglib-location> 220 </taglib> 221 222 <jsp-property-group> 223 <description> 224 Special property group for JSP Configuration JSP example. 225 </description> 226 <display-name>JSPConfiguration</display-name> 227 <url-pattern>/jsp/jsp2/misc/config.jsp</url-pattern> 228 <el-ignored>true</el-ignored> 229 <page-encoding>ISO-8859-1</page-encoding> 230 <scripting-invalid>true</scripting-invalid> 231 <include-prelude>/jsp/jsp2/misc/prelude.jspf</include-prelude> 232 <include-coda>/jsp/jsp2/misc/coda.jspf</include-coda> 233 </jsp-property-group> 234 </jsp-config> 235 236 <security-constraint> 237 <display-name>Example Security Constraint - part 1</display-name> 238 <web-resource-collection> 239 <web-resource-name>Protected Area - Allow methods</web-resource-name> 240 <!-- Define the context-relative URL(s) to be protected --> 241 <url-pattern>/jsp/security/protected/*</url-pattern> 242 <!-- If you list http methods, only those methods are protected so --> 243 <!-- the constraint below ensures all other methods are denied --> 244 <http-method>DELETE</http-method> 245 <http-method>GET</http-method> 246 <http-method>POST</http-method> 247 <http-method>PUT</http-method> 248 </web-resource-collection> 249 <auth-constraint> 250 <!-- Anyone with one of the listed roles may access this area --> 251 <role-name>tomcat</role-name> 252 <role-name>role1</role-name> 253 </auth-constraint> 254 </security-constraint> 255 <security-constraint> 256 <display-name>Example Security Constraint - part 2</display-name> 257 <web-resource-collection> 258 <web-resource-name>Protected Area - Deny methods</web-resource-name> 259 <!-- Define the context-relative URL(s) to be protected --> 260 <url-pattern>/jsp/security/protected/*</url-pattern> 261 <http-method-omission>DELETE</http-method-omission> 262 <http-method-omission>GET</http-method-omission> 263 <http-method-omission>POST</http-method-omission> 264 <http-method-omission>PUT</http-method-omission> 265 </web-resource-collection> 266 <!-- An empty auth constraint denies access --> 267 <auth-constraint /> 268 </security-constraint> 269 270 <!-- Default login configuration uses form-based authentication --> 271 <login-config> 272 <auth-method>FORM</auth-method> 273 <realm-name>Example Form-Based Authentication Area</realm-name> 274 <form-login-config> 275 <form-login-page>/jsp/security/protected/login.jsp</form-login-page> 276 <form-error-page>/jsp/security/protected/error.jsp</form-error-page> 277 </form-login-config> 278 </login-config> 279 280 <!-- Security roles referenced by this web application --> 281 <security-role> 282 <role-name>role1</role-name> 283 </security-role> 284 <security-role> 285 <role-name>tomcat</role-name> 286 </security-role> 287 288 <!-- Environment entry examples --> 289 <!--env-entry> 290 <env-entry-description> 291 The maximum number of tax exemptions allowed to be set. 292 </env-entry-description> 293 <env-entry-name>maxExemptions</env-entry-name> 294 <env-entry-type>java.lang.Integer</env-entry-type> 295 <env-entry-value>15</env-entry-value> 296 </env-entry--> 297 <env-entry> 298 <env-entry-name>minExemptions</env-entry-name> 299 <env-entry-type>java.lang.Integer</env-entry-type> 300 <env-entry-value>1</env-entry-value> 301 </env-entry> 302 <env-entry> 303 <env-entry-name>foo/name1</env-entry-name> 304 <env-entry-type>java.lang.String</env-entry-type> 305 <env-entry-value>value1</env-entry-value> 306 </env-entry> 307 <env-entry> 308 <env-entry-name>foo/bar/name2</env-entry-name> 309 <env-entry-type>java.lang.Boolean</env-entry-type> 310 <env-entry-value>true</env-entry-value> 311 </env-entry> 312 <env-entry> 313 <env-entry-name>name3</env-entry-name> 314 <env-entry-type>java.lang.Integer</env-entry-type> 315 <env-entry-value>1</env-entry-value> 316 </env-entry> 317 <env-entry> 318 <env-entry-name>foo/name4</env-entry-name> 319 <env-entry-type>java.lang.Integer</env-entry-type> 320 <env-entry-value>10</env-entry-value> 321 </env-entry> 322 323 <!-- Async examples --> 324 <servlet> 325 <servlet-name>async0</servlet-name> 326 <servlet-class>async.Async0</servlet-class> 327 <async-supported>true</async-supported> 328 </servlet> 329 <servlet-mapping> 330 <servlet-name>async0</servlet-name> 331 <url-pattern>/async/async0</url-pattern> 332 </servlet-mapping> 333 <servlet> 334 <servlet-name>async1</servlet-name> 335 <servlet-class>async.Async1</servlet-class> 336 <async-supported>true</async-supported> 337 </servlet> 338 <servlet-mapping> 339 <servlet-name>async1</servlet-name> 340 <url-pattern>/async/async1</url-pattern> 341 </servlet-mapping> 342 <servlet> 343 <servlet-name>async2</servlet-name> 344 <servlet-class>async.Async2</servlet-class> 345 <async-supported>true</async-supported> 346 </servlet> 347 <servlet-mapping> 348 <servlet-name>async2</servlet-name> 349 <url-pattern>/async/async2</url-pattern> 350 </servlet-mapping> 351 <servlet> 352 <servlet-name>async3</servlet-name> 353 <servlet-class>async.Async3</servlet-class> 354 <async-supported>true</async-supported> 355 </servlet> 356 <servlet-mapping> 357 <servlet-name>async3</servlet-name> 358 <url-pattern>/async/async3</url-pattern> 359 </servlet-mapping> 360 <servlet> 361 <servlet-name>stock</servlet-name> 362 <servlet-class>async.AsyncStockServlet</servlet-class> 363 <async-supported>true</async-supported> 364 </servlet> 365 <servlet-mapping> 366 <servlet-name>stock</servlet-name> 367 <url-pattern>/async/stockticker</url-pattern> 368 </servlet-mapping> 369 370 <!-- Non-blocking IO examples --> 371 <servlet> 372 <servlet-name>bytecounter</servlet-name> 373 <servlet-class>nonblocking.ByteCounter</servlet-class> 374 <async-supported>true</async-supported> 375 </servlet> 376 <servlet-mapping> 377 <servlet-name>bytecounter</servlet-name> 378 <url-pattern>/servlets/nonblocking/bytecounter</url-pattern> 379 </servlet-mapping> 380 <servlet> 381 <servlet-name>numberwriter</servlet-name> 382 <servlet-class>nonblocking.NumberWriter</servlet-class> 383 <async-supported>true</async-supported> 384 </servlet> 385 <servlet-mapping> 386 <servlet-name>numberwriter</servlet-name> 387 <url-pattern>/servlets/nonblocking/numberwriter</url-pattern> 388 </servlet-mapping> 389 390 <welcome-file-list> 391 <welcome-file>index.html</welcome-file> 392 <welcome-file>index.xhtml</welcome-file> 393 <welcome-file>index.htm</welcome-file> 394 <welcome-file>index.jsp</welcome-file> 395 </welcome-file-list> 396 397 </web-app>