|
|
Next: Generic Servlet Example Up: Lecture 13 Previous: Servlets under Java Web Server
Servlet Interface
All servlets implement javax.servlet.Servlet interface
| init(ServletConfig) | initialize servlet once on loading |
| service() | invoke servlet |
| getServletConfig() | get servlet configuration - passed to init() |
| destroy() | terminate servlet |
Wee.java uses GenericServlet implementation of this interface.
When first loaded Wee class
Each time Wee's service method is run, it
On termination Wee.java saves current value of count in file.
Loaded servlets are terminated when servlets engine is terminated.
This example can be built on anubis as follows:
Declare servlet in $TOMCAT_HOME/demo/WEB-INF/web.xml with
| Lecture 13 | XHTML 1.0 | Slide 6 |