In this section, we begin the study of web components present in Java EE 7 and supported by WildFly 10, starting from the servlets. Let's start with a simple example of a servlet:
@WebServlet("/SimpleServlet")
public class SimpleServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
response.getWriter().print("my GET");
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
response.getWriter().print("my POST");
}
}
This servlet represents two HTTP methods, GET and POST, represented by the doGet and doPost methods inherited by the javax.servlet.http.HttpServlet abstract class.
More information on...