title: How to programmatically add MULTIPLE servlets in Java EE
body: <p>How can i map multiple Servlets 3.0 programmatically (not using deployment descriptor web.xml)</p>
  
  <p>What i have is folling code which works great... but i could not found any way about adding/mapping more than one servlet to an url-pattern:</p>
  
  <pre><code>@WebListener
  public class NewServletListener implements ServletContextListener {
  
  @Override
  public void contextInitialized(ServletContextEvent sce) {
      ServletContext sc = sce.getServletContext();
      ServletRegistration sr = sc.addServlet("test", "BusinessObjects.test");  
      sr.addMapping("/test"); 
  }
  
  @Override
  public void contextDestroyed(ServletContextEvent sce) {
      throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
  }
  }
  </code></pre>
  
  <p>What i need is some kind of this: </p>
  
  <pre><code>ServletRegistration sr = sc.addServlet("testA", "BusinessObjects.testA");  
  sr.addMapping("/testA"); 
  
  ServletRegistration sr2 = sc.addServlet("testB", "BusinessObjects.testB");  
  sr2.addMapping("/testB"); 
  
  ServletRegistration sr3 = sc.addServlet("testC", "BusinessObjects.testC");  
  sr3.addMapping("/testC");
  </code></pre>
  
  <p>and so on... </p>
  
  <p>but this way does not work, i event tried an array... what im doing wrong?</p>
  
  <p>thank you so much for help </p>