How do I execute a sequence of servlets?
        Posted  
        
            by Legend
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Legend
        
        
        
        Published on 2010-06-11T17:42:18Z
        Indexed on 
            2010/06/11
            17:42 UTC
        
        
        Read the original article
        Hit count: 349
        
I have some servlets that act as individual URLs for populating a database for some dummy testing. Something of the form:
public class Populate_ServletName extends HttpServlet {
  public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
     resp.setContentType("text/plain");
     //Insert records
     //Print confirmation
  }
}
I have about 6 such servlets which I want to execute in a sequence. I was thinking of using setLocation to set the next page to be redirected but was not sure if this is the right approach because the redirects should happen after the records have been inserted. Specifically, I am looking for something like this:
public class Populate_ALL extends HttpServlet {
  public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
     resp.setContentType("text/plain");
     //Call Populate_1
     //Call Populate_2
     //Call Populate_3
     //...
  }
}
Any suggestions?
© Stack Overflow or respective owner