Jsp&Servelet 学习笔记(5)

网络整理 - 07-27
1.5创建一个部署描述文件
 
·为你的servlets注册并且创建一个url mapping
·注册并指定应用中的监听器和过滤器
·指定上下文中的初始化参数。
·配置错误页,和欢迎页
·配置seeion 超时
 <?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"  "">
<web-app> 
     <display-name>Servlet 2.3 deployment descriptor</display-name>
     <filter>
         <filter-name>RequestFilter</filter-name>
         <filter-class>com.mydev.RequestFilter</filter-class>
     </filter>
     <filter-mapping> 
        <filter-name>RequestFilter</filter-name> 
        <url-pattern>/*</url-pattern>
     </filter-mapping> 
     <listener>  
        <listener-class>com.mydev.ReqListener</listener-class>
     </listener>
     <servlet>
        <servlet-name>MyServlet</servlet-name> 
        <servlet-class>com.mydev.MyServlet</servlet-class>
      </servlet> 
      <servlet-mapping> 
         <servlet-name> MyServlet </servlet-name>  
         <url-pattern>/myservlet</url-pattern> 
      </servlet-mapping>
      <session-config> 
         <session-timeout>15</session-timeout>
         </session-config>  <error-page> 
      <error-code>404</error-code> 
          <location>/err404.jsp</location>
      </error-page>
</web-app>

资料引用: