void ProductDetails::show_product(HttpServletRequest& request, HttpServletResponse &response) { string id = request.getParameter("product_id"); if(id.empty()) throw runtime_error("ProductDetails: product_id parameter not supplyed"); Product product = fetch(id); request.setAttribute("product", product); request.getRequestDispatcher("ProductDetailsView.csp")->forward(request,response); }
void ProductDetails::doGet(HttpServletRequest& request, HttpServletResponse &response) { try{ request.getSession(true); //start session show_product(request, response); }catch(const exception& ex) { request.setAttribute<string>("error",ex.what()); request.setAttribute("product",Product()); request.getRequestDispatcher("ProductDetailsView.csp")->forward(request,response); } }
void IncludeTestServlet::doGet(HttpServletRequest& req, HttpServletResponse& resp) { ServletOutputStream& os = resp.getOutputStream(); os << "<html><body>Include Servlet BEGIN >>"; HttpRequestDispatcher* prd = dynamic_cast<HttpRequestDispatcher*>(&req.getRequestDispatcher("/ServletTest/IncludedTestServlet")); poco_check_ptr(prd); prd->include(req, resp); os << "<< Include Servlet END</body></html>"; }
void Products::doGet(HttpServletRequest& request, HttpServletResponse &response) { try{ request.setAttribute("categories", fetch_categories()); process(request, response); }catch(const exception& ex) { request.setAttribute<string>("error",ex.what()); request.setAttribute("ResultsFound", 0); request.setAttribute("products", products_t()); request.setAttribute("naviLink",string()); request.setAttribute("currentPage", 0); } request.getRequestDispatcher("ProductsView.csp")->forward(request,response); }
void ProductDetails::doPost(HttpServletRequest& request, HttpServletResponse &response) { try{ try{ add_to_cart(request, response); }catch(const exception& ex) { request.setAttribute<string>("error",ex.what()); show_product(request, response); } }catch(const exception& ex) { request.setAttribute<string>("error",ex.what()); request.setAttribute("product",Product()); request.getRequestDispatcher("ProductDetailsView.csp")->forward(request,response); } }
void ForwardTestServlet::doGet(HttpServletRequest& req, HttpServletResponse& resp) { HttpRequestDispatcher& rd = static_cast<HttpRequestDispatcher&>(req.getRequestDispatcher("/ServletTest/ForwardedTestServlet")); rd.forward(req, resp); }