天行健,君子以自強不息

          BlogJava 首頁 新隨筆 聯系 聚合 管理
            12 Posts :: 0 Stories :: 2 Comments :: 0 Trackbacks

            Tomcat 是一個基于組件的服務器,它的構成組件是可配置的,其中最外層的組件是 Catalina Servlet 容器,其他的組件都是按照一定的格式要求配置在這個頂層容器中。

          Tomcat的各個組件在$CATALINA_HOME/conf/server.xml文件中配置,其基本結構如下:

          <Server>				
          <Service>
          <Connector />
          <Engine>
          <Host>
          <Context />
          </Host>
          </Engine>
          </Service>
          <Server>

           繪圖9

          web.xml文件基本格式:(大小寫敏感、元素次序敏感)

          <?xml version="1.0" encoding="ISO-8859-1"?>
          <!DOCTYPE web-app PUBLIC "-//Sun Mivorsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
          <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
          version="2.4">
          <icon>
          <small-icon>/images/app_small.gif</small-icon>
          <large-icon>/images/app_large.gif</large-icon>
          </icon>
          <display-name>Application name</display-name>
          <description>Description</description>
          <distribute />
          <context-param>
          <param-name>contextParameter</param-name>
          <param-value>test</param-value>
          <description>It is a test parameter.</description>
          </context-param>
          <filter>
          <filter-name>Set Character Encoding</filter-name>
          <filter-class>filters.SetCharacterEncodingFilter</filter-class>
          <init-param>
          <param-name>encoding</param-name>
          <param-value>EUC JP</param-value>
          </init-param>
          </filter>
          <filter-mapping>
          <filter-name>Set Character Encoding</filter-name>
          <url-pattern>/*</url-pattern>
          </filter-mapping>
          <listener>
          <listener-class>listeners.SessionListener</listener-class>
          </listener>
          <servlet>
          <servlet-name>snoop</servlet-name>
          <servlet-class>SnoopServlet</servlet-class>
          <init-param>
          <param-name>foo</param-name>
          <param-value>bar</param-value>
          </init-param>
          <run-as>
          <description>Security role for anonymous access</description>
          <role-name>tomcat</role-name>
          </run-as>
          <load-on-startup>1</load-on-statup>
          </servlet>
          <servlet>
          <servlet-name>JspServlet</servlet-name>
          <jsp-file>/test.jsp</jsp-file>
          <init-param>
          <param-name>firstName</param-name>
          <param-value>tomcat</param-value>
          </init-param>
          <load-on-startup>2</load-on-startup>
          </servlet>
          <servlet-mapping>
          <servlet-name>snoop</servlet-name>
          <url-pattern>/snoop</servlet-name>
          </servlet-mapping>
          <session-config>
          <session-timeout>120</session-timeout>
          </session-config>
          <mime-mapping>
          <extension>htm</extension>
          <mime-type>text/html</mime-type>
          </mime-mapping>
          <welcome-file-list>
          <welcome-file>index.jsp</welcome-file>
          <welcome-file>index.html</welcome-file>
          </welcome-file-list>
          <error-page>
          <error-code>404</error-code>
          <location>/404.jsp</location>
          </error-page>
          <error-page>
          <exception-type>packagename.classname</exception-type>
          <location>exception.jsp</location>
          </error-page>
          <taglib>
          <taglib-url>http://jakarta.apache.org/tomcat/debug-taglib</taglib-uri>
          <taglib-location>/WEB-INF/jsp/debug-taglib.tld</taglib-location>
          </taglib>
          <resource-env-ref>
          <resource-env-ref-name>jms/StockQueue</resource-env-ref-name>
          </resource-env-ref>
          <resource-ref>
          <res-ref-name>mail/Session</res-ref-name>
          <res-type>javax.mail.Sesssion</res-type>
          <res-auth>Container</res-auth>
          <resource-ref>
          <security-constraint>
          <display-name>Example Security Constraint</display-name>
          <web-resource-collection>
          <web-resource-name>Protected Area</web-resource-name>
          <url-pattern>/jsp/security/proctected/*</url-pattern>
          <http-method>DELETE</http-method>
          <http-method>GET</http-method>
          <http-method>POST</http-method>
          <http-method>PUT</http-method>
          </web-resource-collection>
          <auth-constraint>
          <role-name>tomcat</role-name>
          <role-name>role1</role-name>
          </auth-constraint>
          </security-constraint>
          <login-config>
          <auth-method>FORM</auth-method>
          <realm-name>Example Form-Based Authentication Area</realm-name>
          <form-login-config>
          <form-login-page>/jsp/security/protected/login.jsp</form-login-page>
          <form-error-page>/jsp/security/protected/error.jsp</form-error-page>
          </form-login-config>
          </login-config>
          <security-role>
          <role-name>tomcat</role-name>
          </security-role>
          <env-entry>
          <env-entry-name>minExemptions</env-entry-name>
          <env-entry-value>1</env-entry-value>
          <env-entry-type>java.lang.Integer</env-entry-type>
          </env-entry>
          <ejb-ref>
          <description>Example EJB Reference</description>
          <ejb-ref-name>ejb/Account</ejb-ref-name>
          <ejb-ref-type>Entity</ejb-ref-type>
          <home>com.mycompany.mypackage.AccountHome</home>
          <remote>com.mycompany.mypackage.AccountRemote</remote>
          </ejb-ref>
          <ejb-local-ref>
          <description>Example Local EJB Reference</description>
          <ejb-ref-name>ejb/ProcessOrder</ejb-ref-name>
          <ejb-ref-type>Session</ejb-ref-type>
          <local-home>com.mycompany.mypackage.ProcessOrderHome</local-home>
          <local>com.mycompany.mypackage.ProcessOrder</local>
          </ejb-local-ref>
          </web-app>
           
          servlet 2.4中新增標簽:
          <locale-encoding-mapping-list>
          <locale-encoding-mapping>
          <locale>ja</locale>
          <encoding>Shift_JIS</encoding>
          </locale-encoding-mapping>
          <locale-encoding-mapping>
          <locale>zh_TW</locale>
          <encoding>Big5</encoding>
          </locale-encoding-mapping>
          </locale-encoding-mapping-list>
          <filter-mapping>
          <filter-name>Logging Filter</filter-name>
          <url-pattern>/products/*</url-pattern>
          <dispatcher>REQUEST</dispatcher>
          <dispatcher>FORWARD</dispatcher>
          <dispatcher>INCLUDE</dispatcher>
          <dispatcher>ERROR</dispatcher>
          </filter-mapping>
          <jsp-config>
          <taglib>
          <taglib-uri>Taglib</taglib-uri>
          <taglib-location>/WEB-INF/tlds/mytaglib.tld</taglib-location>
          </taglib>
          <jsp-property-group>
          <description>Special property group for jsp configuration.</description>
          <display-name>JspConfiguration</display-name>
          <url-pattern>/jsp/*</url-pattern>
          <el-ignored>true</el-ignored>
          <page-encoding>UTF-8</page-encoding>
          <scripting-invalid>true</scripting-invalid>
          <include--prelude>/include/prelude.jsp</include-prelude>
          <include-coda>/include/coda.jsp</include-coda>
          </jsp-property-group>
          </jsp-config>
          posted on 2008-03-31 22:17 yill 閱讀(251) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 新泰市| 滨海县| 庄河市| 景东| 张掖市| 腾冲县| 收藏| 汉寿县| 资中县| 永康市| 富川| 广州市| 巴楚县| 龙海市| 陆良县| 张北县| 启东市| 德庆县| 涪陵区| 红河县| 兴文县| 泸定县| 潮州市| 淮北市| 和林格尔县| 威远县| 寿光市| 长子县| 华宁县| 华池县| 德格县| 友谊县| 开远市| 吉林省| 华宁县| 都兰县| 哈尔滨市| 静宁县| 天台县| 东兴市| 梁河县|