Servlet 3 allows you to configure your webapplication in Java.
A set of methods have been added to ServletContext to support this, e.g.
- addFilter
- addListener
- addServlet
@WebListener
public class MyServletContextListener implements ServletContextListener {
public void contextInitialized(ServletContextEvent event) {
ServletContext ctx = event.getServletContext();
ServletRegistration servlet = ctx.addServlet ("ProServlet","org.edu.ProServlet");
servlet.addMapping("/dyna/*");
}
public void contextDestroyed(ServletContextEvent event) {}
}
After the ServletContext is initialised, you can't call these methods anymore.
No comments:
Post a Comment