@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
View v = null;
//Debugging
dumpRequest(req);
try {
if (req.getParameterMap().containsKey(Parameters.LOGIN.getId())) {
CustomerHandler vh = new CustomerHandler(req);
v = vh.getLoginView("Please Login");
}
else if (req.getParameterMap().containsKey(Parameters.LOGOUT.getId())) {
CustomerHandler vh = new CustomerHandler(req);
v = vh.getLogoutView();
}
else if (req.getParameterMap().containsKey(Parameters.MY_ACCOUNT.getId())) {
CustomerHandler vh = new CustomerHandler(req);
v = vh.getMyAccountView();
}
else if (req.getParameterMap().containsKey(Parameters.FORGOT.getId())) {
CustomerHandler vh = new CustomerHandler(req);
v = vh.getForgotPasswordView();
}
else if (req.getParameterMap().containsKey(Parameters.REGISTER.getId())) {
CustomerHandler vh = new CustomerHandler(req);
v = vh.getRegistrationView();
}
else if (req.getParameterMap().containsKey(Parameters.WISHLIST.getId())) {
WishListHandler wlh = new WishListHandler(req);
v = wlh.getWishListView();
}
else if (req.getParameterMap().containsKey(Parameters.VIEW_CART.getId())) {
CartHandler ch = new CartHandler(req);
v = ch.getCartView();
}
else if (req.getParameterMap().containsKey(Parameters.CART_ID.getId())) {
CartHandler ch = new CartHandler(req);
v = ch.getCartView();
}
else if (req.getParameterMap().containsKey(Parameters.CHECKOUT.getId())) {
CartHandler ch = new CartHandler(req);
v = ch.checkout();
}
else if (req.getParameterMap().containsKey(Parameters.CATEGORY_ID.getId())) {
ProductHandler ph = new ProductHandler(req);
v = ph.getCategoryView();
}
else if (req.getParameterMap().containsKey(Parameters.ORDER_ID.getId())) {
OrderHandler oh = new OrderHandler(req);
v = oh.getOrderDetailsView();
}
else if (req.getParameterMap().containsKey(Parameters.ALL_ORDERS.getId())) {
OrderHandler oh = new OrderHandler(req);
v = oh.getCustomerOrders();
}
else if (req.getParameterMap().containsKey(Parameters.OPEN_ORDERS.getId())) {
OrderHandler oh = new OrderHandler(req);
v = oh.getCustomerOrders();
}
else if (req.getParameterMap().containsKey(Parameters.PRODUCT.getId())) {
ProductHandler ph = new ProductHandler(req);
v = ph.getProductView();
}
else if (req.getParameterMap().containsKey(Parameters.ALL_PRODUCTS.getId())) {
ProductHandler ph = new ProductHandler(req);
v = ph.getAllView(false);
}
else if (req.getParameterMap().containsKey(Parameters.FEEDBACK.getId())) {
ServiceCaseHandler ch = new ServiceCaseHandler(req);
v = ch.getFeedbackView();
}
else if (req.getParameterMap().containsKey("error")) {
throw new Exception("Error Test");
}
else {
ProductHandler ph = new ProductHandler(req);
v = ph.getHomePageView();
}
if (v != null) {
if (v.getVisitor() != null) {
l.info("visitor:"+v.getVisitor().toString());
}
else {
l.info("null visitor");
}
l.info(v.toString());
}
else {
v = new View();
l.warning("null view:");
}
v.setServletPath("store");
req.setAttribute(REQUEST_ATTRIBUTE_VIEW, v);
getServletConfig().getServletContext().getRequestDispatcher(
JSP_MAIN).forward(req, resp);