目次 |
---|
・web.xml ・<servlet> ~ </servlet> ・<servlet-mapping> ~ </servlet-mapping> ・<welcome-file-list> ~ </welcome-file-list> ・<session-config> ~ </session-config> |
<?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/dtd/web-app_2_3.dtd"> <web-app> </web-app>web.xmlは<web-app>要素と</web-app>要素に囲まれています。この要素の中に、他の要素を記述します。
<servlet> <servlet-name>aiueo</servlet-name> <servlet-class>com.confrage.TestServlet</servlet-class> </servlet><servlet-class>要素でクラスを指定し、そのクラスを参照する他の要素のために<servlet-name>要素で別名を設定しています。
<servlet-mapping> <servlet-name>aiueo</servlet-name> <url-pattern>/TestServlet</url-pattern> </servlet-mapping><servlet-name>要素からサーブレットクラスはcom.confrage.TestServletになることがわかります。
<welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</welcome-file> </welcome-file-list>最初にindex.html、次にindex.htm、最後にindex.jspを検索します。これをアプリケーション毎のweb.xmlでオーバーライドすることができます。
<welcome-file-list> <welcome-file>index.htm</welcome-file> <welcome-file>index.html</welcome-file> <welcome-file>index.jsp</welcome-file> </welcome-file-list>index.htmを最初に検索するように変更しました。今ファイル構成が以下のようになっているとします。
<session-config> <session-timeout>30</session-timeout> </session-config>tomcat\conf\web.xmlに上記設定をすると全てのWEBアプリのセッションタイムアウトが30分になります。