@Override public void contextInitialized(ServletContextEvent event) { }
<listener> <listener-class>org.blueleek.Listener</listener-class> </listener>
(3) depends on the order of your
java<listener>
elements in the web.xml
@Override public void init(FilterConfig config) throws ServletException { }
<filter> <filter-name>ofilter</filter-name> <filter-class>order.OFilter</filter-class> </filter> <filter-mapping> <filter-name>ofilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
(3) The container uses the <filter-mapping> declarations to decide which filters to apply to a request,and in what order. web
@Override public void init() throws ServletException { super.init(); }
<servlet> <servlet-name>oservlet</servlet-name> <servlet-class>org.blueleek..OServlet</servlet-class> <load-on-startup></load-on-startup> </servlet>
(3) The load-on-startup element indicates that this servlet should be loaded (instantiated and have its init() called) on the startup of the web application. The optional contents of these element must be an integer indicating the order in which the servlet should be loaded. If the value is a negative integer, or the element is not present, the container is free to load the servlet whenever it chooses. If the value is a positive integer or 0, the container must load and initialize the servlet as the application is deployed. The container must guarantee that servlets marked with lower integers are loaded before servlets marked with higher integers. The container may choose the order of loading of servlets with the same load-on-start-up value.app
結論來自: http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd 以及本身動手實驗.ide