Generic Servlets can be generated quite easily. Here is a
stubbed out class:
package com.example;
import javax.servlet.*;
public class MyServlet extends Servlet
{
public MyServlet
{
}
// The init() method gets called when the Servlet is loaded
public void init(ServletConfig config)
throws ServletException
{
try {
//..
} catch (IllegalArgumentException e)
{
System.out.println("Exception " + e.getClass().getName()
+ "(" + e.getMessage() + ") "
+ "caught in MyServlet.init()
method");
e.printStackTrace();
}
}
// below are the methods that a Servlet must implement
// and may be of use
public void service(ServletRequest req, ServletResponse res)
throws ServletException, IOException
{ }
public ServletConfig getServletConfig()
{
//..
}
public String getServletInfo()
{
//..
}
public void destroy()
{
}
}
The way I use this servlet is by adding the following to my web.xml file:
<servlet>
<!-- name to identify the servlet by -->
<servlet-name>
MyServlet
</servlet-name>
<!-- full class path to servlet -->
<servlet-class>
com.example.MyServlet
</servlet-class>
<!-- The order to startup the servlet in -->
<load-on-startup>
0
</load-on-startup>
</servlet>
This starts the servlet on server startup.
I can't think of any references that aren't specific to HttpServlet off the
top of my head but I'll take a look through my favorites and see if I find
anything.
---
Michael Wentzel
Software Developer
<A HREF="http://www.aswethink.com">Software As We Think</A>
<A HREF="mailto:[EMAIL PROTECTED]">Michael Wentzel</A>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]