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
1 2 3 4 5 6 7 8 9 | @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) {} } |
No comments:
Post a Comment