----- Original Message -----
From: <[EMAIL PROTECTED]>
To: "Tomcat Users List" <users@tomcat.apache.org>
Sent: Sunday, October 05, 2008 7:12 AM
Subject: Re: adding servlet definition to context on the fly :Tomcat 5.5
Hi Johnny,
Th code i used is basically the one you have in your last email...
I have an app running in privileged mode, and it has to add a servlet
definition on the fly to another app...so in my app i call a method and
pass the description of the other application as well as the servlet
definition i want to add:
public void addServlet(WebAppConfiguration webApp, DeploymentDescriptor
descriptor) {
org.apache.catalina.Server server = ServerFactory.getServer();
String contextRoot = webApp.getContextRoot();
Service[] services = server.findServices();
Context context = null;
String initParamName = descriptor.getInitParamName();
String initParamValue = descriptor.getInitParamValue();
String servletName = descriptor.getServletName();
String servletClass = descriptor.getServletClass();
for (int i = 0; i < services.length; i++) {
Engine engine = (Engine) services[i].getContainer();
Host host = (Host) engine.findChild(engine.getDefaultHost());
context = (Context) host.findChild(contextRoot);
if (context != null){
break;
}
}
if (context == null)
return;
StandardWrapper
w = (StandardWrapper)context.createWrapper();
w.setName(servletName);
w.setServletName(servletName);
w.setServletClass(servletClass);
w.addInitParameter(initParamName, initParamValue);
context.addChild(w);
context.addServletMapping(descriptor.getUrlPattern(), servletName);
}
ok now see what you up to... will give it a little try... stand back...
doing a kidney transplant.. ha ha
---------------------------------------------------------------------------
HARBOR : http://www.kewlstuff.co.za/index.htm
The most powerful application server on earth.
The only real POJO Application Server.
See it in Action : http://www.kewlstuff.co.za/cd_tut_swf/whatisejb1.htm
---------------------------------------------------------------------------
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]