Hi,
I'll get you started, in my email editor and without even trying to
compile this out of laziness: (But it should be very close)
import org.apache.catalina.Context;
import org.apache.catalina.Engine;
import org.apache.catalina.Host;
import org.apache.catalina.Server;
import org.apache.catalina.ServerFactory;
import org.apache.catalina.Service;
import org.apache.catalina.Wrapper;
public class NotPortable {
public static void addServlet(Class myServletClass, String urlPattern)
{
Server server = ServerFactory.getServer();
Service service = server.findServices()[0];
Engine engine = (Engine) service.getContainer();
Host host = (Host) engine.findChildren()[0];
Context context = (Context) host.findChild("mywebapp");
Wrapper wrapper = context.createWrapper();
wrapper.setServletClass(myServletClass);
wrapper.addMapping(urlPattern);
wrapper.load();
context.addChild(wrapper);
// Optionally context.addServletMapping
}
A production-quality implementation would not hard-code the name of the
webapp, nor would it hard-code the 1st service and 1st host (index [0]
in the above code). It might also pass init parameters, etc, but this
just an example to give you an idea.
Yoav Shapira
Millennium Research Informatics
>-----Original Message-----
>From: Robert Hunt [mailto:[EMAIL PROTECTED]
>Sent: Sunday, August 01, 2004 2:15 AM
>To: [EMAIL PROTECTED]
>Subject: RE: other ways to register a Servlet web application
>
>Regarding this thread and another I just inquired about
>(http://www.mail-archive.com/tomcat-
>[EMAIL PROTECTED]/msg132857.html),
>Yoav, would you have a code example?
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
This e-mail, including any attachments, is a confidential business communication, and
may contain information that is confidential, proprietary and/or privileged. This
e-mail is intended only for the individual(s) to whom it is addressed, and may not be
saved, copied, printed, disclosed or used by anyone else. If you are not the(an)
intended recipient, please immediately delete this e-mail from your computer system
and notify the sender. Thank you.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]