You need to open the page by requesting the servlet URL instead of the JSP URL. This will call the doGet()
method.
Placing JSP in /WEB-INF
effectively prevents the enduser from directly opening it without involvement of the doGet()
method of the servlet. Files in /WEB-INF
are namely not public accessible. So if the preprocessing of the servlet is mandatory, then you need to do so. Put the JSP in /WEB-INF
folder and change the requestdispatcher to point to it.
request.getRequestDispatcher("/WEB-INF/products.jsp").forward(request, response);
But you need to change all existing links to point to the servlet URL instead of the JSP URL.
See also: