Section 15.5. The web.xml File

   

15.5 The web.xml File

It can be useful to know the structure of a web.xml document, as Tomcat expects the elements in the document to come in a certain order and will not function properly otherwise . In this section, we will outline the order of a complete web.xml document. It is not complete, but almost complete, and defines most of the elements you are likely to use without stepping into Enterprise JavaBeans. Remember that you don't need to use any of these elements inside the <web-app> element, but if you do, they must be in this order.

 <?xml version="1.0" encoding="ISO-8859-1"?>  <!DOCTYPE web-app PUBLIC  "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/j2ee/dtd/web-app_2_3.dtd"> <web-app> <!--meta information that GUI tools or IDEs might use     to represent this app --> <icon>     <small-icon>/images/AppRepresentationSM.gif</small-icon>     <large-icon>/images/AppRepresentationLG.gif</large-icon> </icon> <display-name>Java for CF</display-name> <description>my application description</description> <!-- filter --> <filter>     <filter-name>SomeFilter</filter-name>     <filter-class>com.mysite.SomeFilter</filter-class> </filter> <!-- make a mapping for this filter --> <filter-mapping>     <filter-name>SomeFilter</filter-name>     <url-pattern>*.jsp</url-pattern> </filter-mapping> <!-- define a servlet --> <servlet>     <servlet-name>Login</servlet-name>     <servlet-class>com.somesite.Login</servlet-class>     <init-param>         <param-name>paramName</param-name>         <param-value>paramValue</param-value>     </init-param>     <load-on-startup>1</load-on-startup> </servlet> <!-- mapping for another servlet --> <servlet-mapping>     <servlet-name>DBController</servlet-name>     <url-pattern>*.jfcf</url-pattern> </servlet-mapping> <!--set default session timeout in minutes --> <session-config>     <session-timeout>45</session-timeout> </session-config> <!-- set MIME mapping --> <mime-mapping>     <extension>doo</extension>     <mime-type>application/x-something</mime-type> </mime-mapping> <!--default welcome file list --> <welcome-file-list> <welcome-file>login.jsp</welcome-file> </welcome-file-list> <!-- error page --> <error-page>     <error-code>404</error-code>     <location>/errors/a404.jsp</location> </error-page> <!-- define tag library --> <taglib>     <taglib-uri>/store</taglib-uri>     <taglib-location>/WEB-INF/tlds/mylibrary.tld     </taglib-location> </taglib> <!-- define a container level security constraint --> <security-constraint>     <web-resource-collection>        <web-resource-name>Java for CF app</web-resource-name>          <url-pattern>/*</url-pattern>        </web-resource-collection>     <auth-constraint>        <role-name>javaforcfusers</role-name>     </auth-constraint> </security-constraint> <!-- define login configuration --> <login-config>     <auth-method>BASIC</auth-method>     <realm-name>My App</realm-name> </login-config> </web-app> 

   
Top


Java for ColdFusion Developers
Java for ColdFusion Developers
ISBN: 0130461806
EAN: 2147483647
Year: 2005
Pages: 206
Authors: Eben Hewitt

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net