@@ -0,0 +1,3420 @@
+/*%0A * To change this license header, choose License Headers in Project Properties.%0A * To change this template file, choose Tools %7C Templates%0A * and open the template in the editor.%0A */%0Apackage controller;%0A%0Aimport java.io.IOException;%0Aimport java.io.PrintWriter;%0Aimport javax.servlet.ServletException;%0Aimport javax.servlet.annotation.WebServlet;%0Aimport javax.servlet.http.HttpServlet;%0Aimport javax.servlet.http.HttpServletRequest;%0Aimport javax.servlet.http.HttpServletResponse;%0A%0A/**%0A *%0A * @author Vonk%0A */%0A@WebServlet(name = %22ControllerServlet%22,%0A        loadOnStartup = 1,%0A        urlPatterns = %7B%0A            %22/category%22,%0A            %22/addToCart%22,%0A            %22/viewCart%22,%0A            %22/updateCart%22,%0A            %22/checkout%22,%0A            %22/purchase%22,%0A            %22/chooseLanguage%22%7D)%0Apublic class ControllerServlet extends HttpServlet %7B%0A%0A    /**%0A     * Handles the HTTP %3Ccode%3EGET%3C/code%3E method.%0A     * @param request servlet request%0A     * @param response servlet response%0A     * @throws ServletException if a servlet-specific error occurs%0A     * @throws IOException if an I/O error occurs%0A     */%0A    @Override%0A    protected void doGet(HttpServletRequest request, HttpServletResponse response)%0A    throws ServletException, IOException %7B%0A%0A        String userPath = request.getServletPath();%0A%0A        // if category page is requested%0A        if (userPath.equals(%22/category%22)) %7B%0A            // TODO: Implement category request%0A%0A        // if cart page is requested%0A        %7D else if (userPath.equals(%22/viewCart%22)) %7B%0A            // TODO: Implement cart page request%0A%0A            userPath = %22/cart%22;%0A%0A        // if checkout page is requested%0A        %7D else if (userPath.equals(%22/checkout%22)) %7B%0A            // TODO: Implement checkout page request%0A%0A        // if user switches language%0A        %7D else if (userPath.equals(%22/chooseLanguage%22)) %7B%0A            // TODO: Implement language request%0A%0A        %7D%0A%0A        // use RequestDispatcher to forward request internally%0A        String url = %22/WEB-INF/view%22 + userPath + %22.jsp%22;%0A%0A        try %7B%0A            request.getRequestDispatcher(url).forward(request, response);%0A        %7D catch (Exception ex) %7B%0A            ex.printStackTrace();%0A        %7D%0A    %7D%0A%0A    /**%0A     * Handles the HTTP %3Ccode%3EPOST%3C/code%3E method.%0A     * @param request servlet request%0A     * @param response servlet response%0A     * @throws ServletException if a servlet-specific error occurs%0A     * @throws IOException if an I/O error occurs%0A     */%0A    @Override%0A    protected void doPost(HttpServletRequest request, HttpServletResponse response)%0A    throws ServletException, IOException %7B%0A%0A        String userPath = request.getServletPath();%0A%0A        // if addToCart action is called%0A        if (userPath.equals(%22/addToCart%22)) %7B%0A            // TODO: Implement add product to cart action%0A%0A        // if updateCart action is called%0A        %7D else if (userPath.equals(%22/updateCart%22)) %7B%0A            // TODO: Implement update cart action%0A%0A        // if purchase action is called%0A        %7D else if (userPath.equals(%22/purchase%22)) %7B%0A            // TODO: Implement purchase action%0A%0A            userPath = %22/confirmation%22;%0A        %7D%0A%0A        // use RequestDispatcher to forward request internally%0A        String url = %22/WEB-INF/view%22 + userPath + %22.jsp%22;%0A%0A        try %7B%0A            request.getRequestDispatcher(url).forward(request, response);%0A        %7D catch (Exception ex) %7B%0A            ex.printStackTrace();%0A        %7D%0A    %7D%0A%0A%7D

add ControllerServlet