I have a simple doGet
method on a hyperlink to direct a view cart summary. It works if I run on the servlet
the path is,
http://localhost:9090/WebApp/view_cart
whereas if I run on the JSP
page when I click the below hyperlink, The path is
<form method="GET"> <a href="view_cart"> view cart </a> </form>
http://localhost:9090/WebApp/frontend/view_cart
Here is a doGet method, how can I get the correct path to show the /view_cart page
??
@WebServlet("/view_cart")
public class ViewCartServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
public ViewCartServlet() {
super();
}
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.getWriter().append("Served at: ").append(request.getContextPath());
response.setContentType("text/html");
String viewCart = "frontend/shopping_cart.jsp";
RequestDispatcher rd = request.getRequestDispatcher(viewCart);
rd.forward(request, response);
}
}