// }
public void registerServlet(Servlet servlet, String urlPattern, Dictionary params,
Dictionary servletAttrs, int event, javax.servlet.Filter associatedFilter) throws CarbonException {
HttpService httpService;
try {
httpService = CarbonUIServiceComponent.getHttpService();
} catch (Exception e) {
throw new CarbonException("An instance of HttpService is not available");
}
try {
if (event == ServiceEvent.REGISTERED) {
Servlet adaptedJspServlet = new ContextPathServletAdaptor(servlet, urlPattern);
if (associatedFilter == null) {
httpService.registerServlet(urlPattern, adaptedJspServlet, params, httpContext);
} else {
httpService.registerServlet(urlPattern,
new FilterServletAdaptor(associatedFilter, null, adaptedJspServlet), params, httpContext);
}
if (servletAttrs != null) {
for (Enumeration enm = servletAttrs.keys(); enm.hasMoreElements();) {
String key = (String) enm.nextElement();
adaptedJspServlet.getServletConfig().getServletContext().setAttribute(key, servletAttrs.get(key));
}
}
} else if (event == ServiceEvent.UNREGISTERING) {
httpService.unregister(urlPattern);
}
} catch (Exception e) {
throw new CarbonException("Error occurred while registering servlet", e);
}