'processRequest in the WebServlet is not working/processing

    @WebServlet(
          name = "MainServlet", 
          urlPatterns = "/testservlet")
public class MainServlet extends HttpServlet {

    private static final long serialVersionUID = xxxxx;

    @Autowired
    private MainDao aDao;
    
    @Autowired
    private TstDao cDao;
    
    /**
     * Constructor of the object.
     */
    public MainServlet() {
        super();
    }

    /**
     * Destruction of the servlet. <br>
     */
    public void destroy() {
        super.destroy(); // Just puts "destroy" string in log
        // Put your code here
    }

    /**
     * The doGet method of the servlet. <br>
     *
     * This method is called when a form has its tag value method equals to get.
     * 
     * @param request the request send by the client to the server
     * @param response the response send by the server to the client
     * @throws ServletException if an error occurred
     * @throws IOException if an error occurred
     */
    public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
            processRequest(request, response);
    }

    /**
     * The doPost method of the servlet. <br>
     *
     * This method is called when a form has its tag value method equals to post.
     * 
     * @param request the request send by the client to the server
     * @param response the response send by the server to the client
     * @throws ServletException if an error occurred
     * @throws IOException if an error occurred
     */
    public void doPost(
        HttpServletRequest request,
        HttpServletResponse response)
        throws ServletException, IOException {
            processRequest(request, response);
    }

    /**
     * Initilaisation of the servlet. <br>
     *
     * @throws ServletException if an error occure
     */
    public void init() throws ServletException {
        // Put your code here
    }

    public void processRequest(
        HttpServletRequest request,
        HttpServletResponse response)
        throws ServletException, IOException {
        System.out.print("reached me");
        
        // codes here erased
        url="/jsp/Test.jsp";

        RequestDispatcher rd = getServletContext().getRequestDispatcher(url);
        rd.forward(request, response);

        return;
    }
}

This is the code from the controller package. I access this servlet by: http://localhost:8083/testservlet My jsp files are placed in src/main/resources inside > jsp folder However, upon running the controller via url it is not printing anything. But in the java console it just says: Initializing Spring DispatcherServlet 'dispatcherServlet' Then in web console it says 404. Can you guys enlighten me on this one? I didn't use @Controller since I am just reviving an old code that uses servlets.

Or maybe I just accessed it wrong? http://localhost:8083/testservlet



Solution 1:[1]

Nevermind this one, I just converted it to controller instead.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Iskooolar2 iskoolar2