XMLWordPrintable

    • Icon: Sub-task Sub-task
    • Resolution: Done
    • Icon: Major Major
    • 2.16.1.Final
    • 2.16.0.Final
    • Java EE
    • None

      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");
          }
      }
      

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

                Created:
                Updated:
                Resolved: