Details

    • Sub-task
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Done
    • 2.16.0.Final
    • 2.16.1.Final
    • Java EE
    • None

    Description

      It would be good to have a command to create a Servlet. A command like this :

      servlet-new-servlet --named MyServlet
      

      Would generate

      @WebServlet(urlPatterns = "myServlet")
      public class MyServlet extends HttpServlet 
      {
      }
      

      Changing the urlPattern would be :

      servlet-new-servlet --named MyServlet --urlPatterns myPattern1 myPattern2
      

      This would generate :

      @WebServlet(urlPatterns = { "myPattern1", "myPattern2" })
      public class MyServlet extends HttpServlet 
      {
      }
      

      The command also allows to generate several methods (get, post, put, delete) :

      servlet-new-servlet --named MyServlet --methods GET POST DELETE
      

      This would generate :

      @WebServlet(urlPatterns = "myServlet")
      public class MyServlet extends HttpServlet 
      {
          @Override
          protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
              response.getWriter().println("doGet invoked");
          }
      
          @Override
          protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
              response.getWriter().println("doPost invoked");
          }
      
          @Override
          protected void doDelete(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
              response.getWriter().println("doDelete invoked");
          }
      }
      

      Attachments

        Activity

          People

            agoncal Antonio Goncalves
            agoncal Antonio Goncalves
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: