servlet specification 2.3, chapter10:Application event listeners are classes that implement one or more of the servlet event listener interfaces<Servlet Constext Events>
listener interace: javax.servlet.SerletContextListenerAn Example of listener User:
When the application starts up, the listener class is notified.The application logs on to the database, and stores the connection in the servlet context.
<omited>
listener interace: javax.servlet.SerletContextListenerAn Example of listener User:
When the application starts up, the listener class is notified.The application logs on to the database, and stores the connection in the servlet context.
<omited>
解决方案 »
- TomCat 安装成功后输入 http://localhost:8080怎么没反应??
- 新手jsp第二帖,继续问.另求入门电子图书.
- 关于页面报HTTP Status 500 root cause java.lang.OutOfMemoryError
- 输出数组中重复记录的下标
- 求:JSP+JavaBean的报表及报表的打印功能的例子,
- 100分---关于使用iText,在pdf中插入图片的问题,顶者有分
- 大家帮忙,不然小弟就被开掉了。关于如何实现JSP分页。
- 關於數據庫連接的問題
- 怎么让客户端读取本地机器上的某个文件,并把读到的东西返回到服务器?
- 高分求讲解,关于文件导入MYSQL数据库
- 如何在session过期时提醒用户?
- 请教一个如何访问SERVLET的问题!(急切)
<servlet>
<…………>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>CartServlet</servlet-name> //Servlet类名
<url-pattern>/cart.jsp</url-pattern> //将cart.jsp映射到Servet
</servlet-mapping>
在IE输入.../cart.jsp实际执行的是CartServlet
在web-inf下你可以建立一个web.xml文件,它的格式你可以参考%tomcat%/conf/web.xml来写,可以制定自己应用中用到的servlet。其中有一个<load-on-startup>1</load-on-startup>的标签,来定义servlet的启动时间,1为Tomcat启动时候启动。如果没有在这个文件里声明的得servlet会在第一个用户访问时候启动。但是推荐把所有servlet都在此文件中声明,可以实现servlet的别名访问,只是不写<load-on-startup>1</load-on-startup>,那么它就会在第一个用户访问时在启动了。
good luck...
...
<servlet>
<servlet-name>controller</servlet-name>
<description>
This servlet plays the "controller" role in the MVC architecture
used in this application. It is generally mapped to the ".do"
filename extension with a <servlet-mapping> element, and all form
submits in the app will be submitted to a request URI like
"saveCustomer.do", which will therefore be mapped to this servlet. The initialization parameter namess for this servlet are the
"servlet path" that will be received by this servlet (after the
filename extension is removed). The corresponding value is the
name of the action class that will be used to process this request.
</description>
<servlet-class>com.mycompany.mypackage.ControllerServlet</servlet-class>
<init-param>
<param-name>listOrders</paramName>
<param-value>com.mycompany.myactions.ListOrdersAction</param-value>
</init-param>
<init-param>
<param-name>saveCustomer</paramName>
<param-value>com.mycompany.myactions.SaveCustomerAction</param-value>
</init-param>
<!-- Load this servlet at server startup time -->
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>controller</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>