-
Sub-task
-
Resolution: Done
-
Major
-
2.16.0.Final
-
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"); } }