]
Antonio Goncalves updated FORGE-2323:
-------------------------------------
Status: Pull Request Sent (was: Open)
Git Pull Request:
Being able to create a new servlet
----------------------------------
Key: FORGE-2323
URL:
https://issues.jboss.org/browse/FORGE-2323
Project: Forge
Issue Type: Sub-task
Components: Java EE
Affects Versions: 2.16.0.Final
Reporter: Antonio Goncalves
Assignee: Antonio Goncalves
Fix For: 2.x Future
It would be good to have a command to create a Servlet. A command like this :
{code}
servlet-new-servlet --named MyServlet
{code}
Would generate
{code}
@WebServlet(urlPatterns = "myServlet")
public class MyServlet extends HttpServlet
{
}
{code}
Changing the urlPattern would be :
{code}
servlet-new-servlet --named MyServlet --urlPatterns myPattern1 myPattern2
{code}
This would generate :
{code}
@WebServlet(urlPatterns = { "myPattern1", "myPattern2" })
public class MyServlet extends HttpServlet
{
}
{code}
The command also allows to generate several methods (get, post, put, delete) :
{code}
servlet-new-servlet --named MyServlet --methods GET POST DELETE
{code}
This would generate :
{code}
@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");
}
}
{code}