test
Форк от lirfrnk/test
1package servlets;
2
3import java.io.IOException;
4import java.io.PrintWriter;
5
6import javax.servlet.RequestDispatcher;
7import javax.servlet.ServletException;
8import javax.servlet.http.HttpServlet;
9import javax.servlet.http.HttpServletRequest;
10import javax.servlet.http.HttpServletResponse;
11
12import com.bittercode.constant.BookStoreConstants;
13import com.bittercode.model.UserRole;
14import com.bittercode.util.StoreUtil;
15
16public class CheckoutServlet extends HttpServlet {
17public void doPost(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException {
18PrintWriter pw = res.getWriter();
19res.setContentType(BookStoreConstants.CONTENT_TYPE_TEXT_HTML);
20if (!StoreUtil.isLoggedIn(UserRole.CUSTOMER, req.getSession())) {
21RequestDispatcher rd = req.getRequestDispatcher("CustomerLogin.html");
22rd.include(req, res);
23pw.println("<table class=\"tab\"><tr><td>Please Login First to Continue!!</td></tr></table>");
24return;
25}
26try {
27
28RequestDispatcher rd = req.getRequestDispatcher("payment.html");
29rd.include(req, res);
30StoreUtil.setActiveTab(pw, "cart");
31pw.println("Total Amount<span class=\"price\" style=\"color: black\"><b>₹ "
32+ req.getSession().getAttribute("amountToPay")
33+ "</b></span>");
34
35pw.println("<input type=\"submit\" value=\"Pay & Place Order\" class=\"btn\">"
36+ "</form>");
37
38pw.println("</div>\r\n"
39+ " </div>\r\n"
40+ " </div>\r\n"
41+ " </div>");
42} catch (Exception e) {
43e.printStackTrace();
44}
45}
46
47}
48