{
if (! isInitializing())
throw new IllegalStateException(L.l("addServlet may only be called during initialization"));
try {
ServletConfigImpl config
= (ServletConfigImpl) getServletRegistration(servletName);
if (config == null) {
config = createServlet();
config.setServletName(servletName);
config.setServletClass(servletClassName);
config.setServletClass(servletClass);
config.setServlet(servlet);
addServlet(config);
} else {
if (config.getClassName() == null)
config.setServletClass(servletClassName);
if (config.getServletClass() == null)
config.setServletClass(servletClass);
if (config.getServlet() == null)
config.setServlet(servlet);
}
return config;
}
catch (ServletException e) {