en
Feedback
SCA Projects

SCA Projects

Open in Telegram
385
Subscribers
No data24 hours
-17 days
+130 days
Posts Archive
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html> <html> <head> <title>Order Details</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous"> <link rel="stylesheet" href="mycss.css"> </head> <body style="background-color: #E6F9E6;"> <% /* Java Code */ %> <jsp:include page="header.jsp" /> <div class="text-center text-primary h3 m-3">Order Details</div> <!-- Display Payment Status --> <% /* Java Code */ { %> <div id="message" class="alert alert-info text-center"> <%= /* Java Code */ %> </div> <% } %> <!-- Start of Product Items List --> <div class="container"> <div class="table-responsive "> <table class="table table-hover table-sm"> <thead style="background-color: black; color: white; font-size: 14px; font-weight: bold;"> <tr> <th>Picture</th> <th>Product Name</th> <th>Order ID</th> <th>Quantity</th> <th>Price</th> <th>Time</th> <th>Status</th> </tr> </thead> <tbody> <% /* Java Code */ { %> <tr> <td><img src="./ShowImageServlet?pid=<%= /* Java Code */ %>" style="width: 50px; height: 50px;"></td> <td><%= /* Java Code */ %></td> <td><%= /* Java Code */ %></td> <td><%= /* Java Code */ %></td> <td><%= /* Java Code */ %></td> <td><%= /* Java Code */ %></td> <td class="text-success"><%= /* Java Code */ %></td> </tr> <% /* Java Code */ %> <tr> <td colspan="7" class="text-center">No orders found.</td> </tr> <% } %> </tbody> </table> </div> </div> <!-- End of Product Items List --> <%@ include file="footer.html" %> </body> </html>

package in.gadgethub.servlet; import in.gadgethub.dao.CartDAO; import in.gadgethub.dao.impl.CartDAOImpl; import in.gadgethub.dao.impl.DemandImpl; import in.gadgethub.dao.impl.ProductDaoImpl; import in.gadgethub.pojo.CartPojo; import in.gadgethub.pojo.DemandPojo; import in.gadgethub.pojo.ProductPojo; import java.io.IOException; import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; /** * * @author SCALive */ public class UpdateToCartServlet extends HttpServlet { protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session = request.getSession(); String userName = (String) session.getAttribute("userName"); String password = (String) session.getAttribute("password"); String userType = (String) session.getAttribute("userType"); if (userType == null password == null userName == null || !userType.equalsIgnoreCase("customer")) { response.sendRedirect("login.jsp?message=Access denied ! Please login first"); return; } String prodId = request.getParameter("pid"); int pQty = Integer.parseInt(request.getParameter("pQty")); ProductDaoImpl prodDao = new ProductDaoImpl(); CartDAO cartDao=new CartDAOImpl(); ProductPojo product = prodDao.getProductDetails(prodId); int availableQty = product.getProdQuantity(); if (availableQty < pQty) { String status = "Only " + availableQty + " no of " + product.getProdName() + " are available in the shop!.So we can add only " + availableQty + " products in your cart"; DemandImpl demand = new DemandImpl(); DemandPojo demandPojo = new DemandPojo(userName, prodId, pQty - availableQty); boolean flag = demand.addProduct(demandPojo); if (flag) { status += "<br/>Later we will mail you when " + product.getProdName() + " will be available"; } RequestDispatcher rd = request.getRequestDispatcher("./CartDetailsServlet"); request.setAttribute("message",status); rd.forward(request, response); }else{ String status = cartDao.updateProductInCart(new CartPojo(userName, prodId, pQty)); RequestDispatcher rd = request.getRequestDispatcher("./CartDetailsServlet"); request.setAttribute("message",status); rd.forward(request, response); } }

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html> <html> <head> <title>Payments</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous"> <link rel="stylesheet" href="mycss.css"> </head> <body style="background-color: #E6F9E6;"> <% /* Java Code */ %> <jsp:include page="header.jsp" /> <div class="container"> <div class="row justify-content-center"> <form action="./OrderServlet" method="post" class="col-md-6 col-md-offset-3 myform"> <div class="text-center mt-3"> <div class="form-group"> <img src="images/gateway.png" alt="Payment Proceed" height="100px" /> <h2 class="text-primary">Credit Card Payment</h2> </div> </div> <div class="row mt-3"> <div class="col-md-12 form-group"> <label for="last_name">Name of Card Holder</label> <input type="text" placeholder="Enter Card Holder Name" name="cardholder" class="form-control" id="last_name" required> </div> </div> <div class="row mt-3"> <div class="col-md-12 form-group"> <label for="last_name">Enter Credit Card Number</label> <input type="number" placeholder="4242-4242-4242-4242" name="cardnumber" class="form-control" id="last_name" required> </div> </div> <div class="row mt-3"> <div class="col-md-6 form-group"> <label for="last_name">Expiry Month</label> <input type="number" placeholder="MM" name="expmonth" class="form-control" size="2" max="12" min="00" id="last_name" required> </div> <div class="col-md-6 form-group"> <label for="last_name">Expiry Year</label> <input type="number" placeholder="YYYY" class="form-control" size="4" id="last_name" min="<%/* Java Code */%>" name="expyear" required> </div> </div> <div class="row mt-3 mb-3"> <div class="col-md-6 form-group"> <label for="last_name">Enter CVV</label> <input type="number" placeholder="123" class="form-control" size="3" id="last_name" name="expyear" required> <input type="hidden" name="amount" value="<%/* Java Code */%>"> </div> <div class="col-md-6 form-group"> <label>&nbsp;</label> <button type="submit" class="form-control btn btn-warning"> Pay :Rs <%=/* Java Code */%></button> </div> </div> </form> </div> </div> <!-- ENd of Product Items List --> <%@ include file="footer.jsp"%> </body> </html>

Repost from SCALive
🚀 AJAX & Fetch API Bootcamp 🌟 📅 Date: 4th January 2025 ⏰ Time: 6:00 PM to 8:00 PM 💻 What You’ll Learn: ✔️ Basics of AJAX
🚀 AJAX & Fetch API Bootcamp 🌟 📅 Date: 4th January 2025 ⏰ Time: 6:00 PM to 8:00 PM 💻 What You’ll Learn: ✔️ Basics of AJAX ✔️ Modern Fetch API ✔️ API Calls & Real-world Use Cases 🎓 Who Should Attend: Developers with basic JavaScript knowledge. 📝 Seats Limited! Register Now: 🔗 bit.ly/scaAJAX 📢 Don’t Miss This Chance to Master Asynchronous Web Development! 💡

<%@page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html> <html> <head> <title>Remove Product</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous"> <link rel="stylesheet" href="mycss.css"> </head> <body style="background-color: #E6F9E6;"> <% String userName = (String) session.getAttribute("userName"); String password = (String) session.getAttribute("password"); String userType = (String) session.getAttribute("userType"); if (userType == null || !userType.equalsIgnoreCase("admin")) { response.sendRedirect("login.jsp?message=Access denied ! Please login as admin"); } else if (userName == null || password == null) { response.sendRedirect("login.jsp?message=Session expired ! Please login again"); } %> <jsp:include page="header.jsp" /> <% String message=request.getParameter("message"); %> <div class="container"> <div class="row justify-content-center m-4"> <form action="./RemoveProductServlet" method="post" class="col-md-4 col-md-offset-4 myform p-3"> <div style="font-weight: bold;" class="text-center"> <h3 class="text-primary">Product Deletion Form</h3> <% if(message!=null) { %> <p style="color: blue;"> <%=message%> </p> <% } %> </div> <div></div> <div class="row"> <div class="col-md-12 form-group mt-3"> <label for="last_name">Product Id</label><input type="text" placeholder="Enter Product Id" name="prodid" class="form-control" id="last_name" required> </div> </div> <div class="row mt-3"> <div class="col-md-6 text-center" style="margin-bottom: 2px;"> <a href="AdminViewProductServlet" class="btn btn-info">Cancel</a> </div> <div class="col-md-6 text-center"> <button type="submit" class="btn btn-danger">Remove Product</button> </div> </div> </form> </div> </div> <%@ include file="footer.jsp"%> </body> </html>

public class UpdateToCartServlet extends HttpServlet { protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session = request.getSession(); String userName = (String) session.getAttribute("userName"); String password = (String) session.getAttribute("password"); String userType = (String) session.getAttribute("userType"); if (userType == null password == null userName == null || !userType.equalsIgnoreCase("customer")) { response.sendRedirect("login.jsp?message=Access denied ! Please login first"); return; } String prodId = request.getParameter("pid"); int pQty = Integer.parseInt(request.getParameter("pQty")); ProductDaoImpl prodDao = new ProductDaoImpl(); CartDAO cartDao=new CartDAOImpl(); ProductPojo product = prodDao.getProductDetails(prodId); int availableQty = product.getProdQuantity(); if (availableQty < pQty) { String status = "Only " + availableQty + " no of " + product.getProdName() + " are available in the shop!.So we can add only " + availableQty + " products in your cart"; DemandImpl demand = new DemandImpl(); DemandPojo demandPojo = new DemandPojo(userName, prodId, pQty - availableQty); boolean flag = demand.addProduct(demandPojo); if (flag) { status += "<br/>Later we will mail you when " + product.getProdName() + " will be available"; } RequestDispatcher rd = request.getRequestDispatcher("./CartDetailsServlet"); request.setAttribute("message",status); rd.forward(request, response); }else{ String status = cartDao.updateProductInCart(new CartPojo(userName, prodId, pQty)); RequestDispatcher rd = request.getRequestDispatcher("./CartDetailsServlet"); request.setAttribute("message",status); rd.forward(request, response); } }

public class CartDetailsServlet extends HttpServlet { protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session = request.getSession(); String userName = (String) session.getAttribute("userName"); String password = (String) session.getAttribute("password"); String userType = (String) session.getAttribute("userType"); if (userType == null password == null userName == null || !userType.equalsIgnoreCase("customer")) { response.sendRedirect("login.jsp?message=Access denied ! Please login first"); return; } String addStr=request.getParameter("add"); if(addStr!=null){ int add=Integer.parseInt(addStr); String uid=request.getParameter("uid"); String pid=request.getParameter("pid"); int avail=Integer.parseInt(request.getParameter("avail")); int cartQty=Integer.parseInt(request.getParameter("qty")); CartDAO cartDao=new CartDAOImpl(); if(add==1){ cartQty+=1; CartPojo cartPojo=new CartPojo(); cartPojo.setProdId(pid); cartPojo.setQuantity(1); cartPojo.setUseremail(uid); cartDao.addProductToCart(cartPojo); }else if(add==0){ cartQty-=1; CartPojo cartPojo=new CartPojo(); cartPojo.setProdId(pid); cartPojo.setQuantity(cartQty); cartPojo.setUseremail(uid); cartDao.updateProductInCart(cartPojo); } } CartDAOImpl cartDao=new CartDAOImpl(); ProductDaoImpl productDao=new ProductDaoImpl(); List<CartPojo>cartItems=new ArrayList<>(); cartItems=cartDao.getAllCartItems(userName); Map<String,Object>map=new HashMap<>(); for(CartPojo cp:cartItems){ String prodId=cp.getProdId(); ProductPojo product=productDao.getProductDetails(prodId); map.put(prodId,product); } RequestDispatcher rd=request.getRequestDispatcher("cartDetails.jsp"); request.setAttribute("userName",userName); request.setAttribute("cartItems",cartItems); request.setAttribute("map",map); rd.forward(request, response); }

--> <%@ include file="footer.jsp"%>

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@ page import="in.gadgethub.dao.impl.*,in.gadgethub.dao.*,in.gadgethub.pojo.*,javax.servlet.ServletOutputStream,java.io.*,java.util.*" %> <!DOCTYPE html> <html> <head> <title>Cart Details</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous"> <link rel="stylesheet" href="mycss.css"> </head> <body style="background-color: #E6F9E6;"> <jsp:include page="header.jsp" /> <div class="text-center h3 m-3 text-primary">Cart Items</div> <div class="container"> <table class="table table-hover"> <thead> <tr> <th>Picture</th> <th>Products</th> <th>Price</th> <th>Quantity</th> <th>Add</th> <th>Remove</th> <th>Amount</th> </tr> </thead> <tbody> <% String userName=(String)request.getAttribute("userName"); List<CartPojo>cartItems=(List<CartPojo>)request.getAttribute("cartItems"); Map<String,Object>map=(Map<String,Object>)request.getAttribute("map"); double totalAmount=0.0; for(CartPojo item:cartItems){ String prodId=item.getProdId(); int prodQuantity=item.getQuantity(); ProductPojo product=(ProductPojo)map.get(prodId); double prodPrice=product.getProdPrice(); double currAmount=prodQuantity*prodPrice; totalAmount+=currAmount; if(prodQuantity>0){ %> <tr> <td><img src="./ShowImageServlet?pid=<%=product.getProdId()%>" style="width: 50px; height: 50px;"></td> <td><%=product.getProdName()%></td> <td><%=product.getProdPrice()%></td> <td><form method="post" action="./UpdateToCartServlet"> <input type="number" name="pqty" value="<%=prodQuantity%>" style="max-width: 70px;" min="0"><input type="hidden" name="pid" value="<%=product.getProdId()%>"><input type="submit" name="Update" value="Update" style="max-width: 80px;"> </form></td> <td><a href="CartDetailServlet?add=1&uid=<%=userName%>&pid=<%=product.getProdId()%>&avail=<%=product.getProdQuantity()%>&qty=<%=prodQuantity%>"><i class="fa fa-plus"></i></a></td> <td><a href="CartDetailServlet?add=0&uid=<%=userName%>&pid=<%=product.getProdId()%>&avail=<%=product.getProdQuantity()%>&qty=<%=prodQuantity%>"><i class="fa fa-minus"></i></a></td> <td><%=currAmount%></td> </tr> <% } } %> <tr style="background-color: grey; color: white;"> <td colspan="6" style="text-align: center;">Total Amount to Pay (in Rupees)</td> <td><%=totalAmount%></td> </tr> <% if(totalAmount!=0) { %> <tr style="background-color: grey; color: white;"> <td colspan="4" style="text-align: center;"> <td><form method="post"> <button formaction="UserHomeServlet" style="background-color: black; color: white;">Cancel</button> </form></td> <td colspan="2" align="center"><form method="post"> <button style="background-color: blue; color: white;" formaction="payment.jsp?amount=<%= totalAmount%>">Pay Now</button> </form></td> </tr> <% } %> </tbody> </table> </div> <!-- ENd of Product Items List

public class UserHomeServlet extends HttpServlet { protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session = request.getSession(); String userName = (String) session.getAttribute("userName"); String password = (String) session.getAttribute("password"); String userType = (String) session.getAttribute("userType"); if (userType == null || !userType.equalsIgnoreCase("customer")) { response.sendRedirect("login.jsp?message=Access denied ! Please login as customer"); } else if (userName == null || password == null) { response.sendRedirect("login.jsp?message=Session expired ! Please login again"); } ProductDaoImpl productDao = new ProductDaoImpl(); String search = request.getParameter("search"); String type = request.getParameter("type"); CartDAOImpl cartDao=new CartDAOImpl(); String message = "All Products"; List products = new ArrayList<>(); if (search != null) { products = productDao.searchAllProducts(search); message = "Showing results for '" + search + "'"; } else if (type != null) { products = productDao.getAllProductsByType(type); message = "Showing results for '" + type + "'"; } else { products = productDao.getAllProducts(); } if (products.isEmpty()) { products = productDao.getAllProducts(); message = "No items found for '" + (search != null ? search : type) + "'"; } Map map = new HashMap<>(); for (ProductPojo product : products) { int qty = cartDao.getCartItemCount(userName, product.getProdId()); map.put(product.getProdId(), qty); } RequestDispatcher rd=request.getRequestDispatcher("userhome.jsp"); request.setAttribute("userName",userName); request.setAttribute("message",message); request.setAttribute("products",products); request.setAttribute("map",map); rd.forward(request, response); }

public class CartDetailsServlet extends HttpServlet { protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session = request.getSession(); String userName = (String) session.getAttribute("userName"); String password = (String) session.getAttribute("password"); String userType = (String) session.getAttribute("userType"); if (userType == null password == null userName == null || !userType.equalsIgnoreCase("customer")) { response.sendRedirect("login.jsp?message=Access denied ! Please login first"); return; } //some more code will come here CartDAOImpl cartDao=new CartDAOImpl(); ProductDaoImpl productDao=new ProductDaoImpl(); List<CartPojo>cartItems=new ArrayList<>(); cartItems=cartDao.getAllCartItems(userName); Map<String,Object>map=new HashMap<>(); for(CartPojo cp:cartItems){ String prodId=cp.getProdId(); ProductPojo product=productDao.getProductDetails(prodId); map.put(prodId,product); } RequestDispatcher rd=request.getRequestDispatcher("cartDetails.jsp"); request.setAttribute("userName",userName); request.setAttribute("cartItems",cartItems); request.setAttribute("map",map); rd.forward(request, response); }

protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter pw = response.getWriter(); HttpSession session = request.getSession(); String userName = (String) session.getAttribute("userName"); String password = (String) session.getAttribute("password"); String userType = (String) session.getAttribute("userType"); if (userType == null password == null userName == null || !userType.equalsIgnoreCase("customer")) { response.sendRedirect("login.jsp?message=Access denied ! Please login first"); return; } String userId = userName; String prodId = request.getParameter("pid"); int pQty = Integer.parseInt(request.getParameter("pqty")); String action = request.getParameter("action"); CartDAOImpl cartDao = new CartDAOImpl(); ProductDaoImpl productDao = new ProductDaoImpl(); ProductPojo productPojo = productDao.getProductDetails(prodId); int avQty = productDao.getProductQuantity(prodId); int cartQty = cartDao.getCartItemCount(userId, prodId); pQty += cartQty; if (action != null) { cartDao.updateProductInCart(new CartPojo(userId, prodId, pQty)); RequestDispatcher rd = request.getRequestDispatcher("./CartDetailsServlet"); rd.forward(request, response); } else if (pQty == cartQty) { String status = cartDao.removeProductFromCart(userId, prodId); RequestDispatcher rd = request.getRequestDispatcher("userHome.jsp"); pw.println("<script>document.getElementById('message').innerHTML='" + status + "'</script>"); rd.include(request, response); } else if (avQty < pQty) { String status = null; if (avQty == 0) { status = "Product out of stock!"; } else { cartDao.updateProductInCart(new CartPojo(userId, prodId, avQty)); status = "Only " + avQty + " no of " + productPojo.getProdName() + " are available, so we are adding only " + avQty + " products in your cart"; } DemandImpl demand = new DemandImpl(); DemandPojo demandPojo = new DemandPojo(userId, prodId, pQty - avQty); boolean flag = demand.addProduct(demandPojo); if (flag) { status += "<br/>Later we will mail you when " + productPojo.getProdName() + " will be available"; } RequestDispatcher rd = request.getRequestDispatcher("./CartDetailsServlet"); pw.println("<script>document.getElementById('message').innerHTML='" + status + "'</script>"); rd.include(request, response); } else { String status = cartDao.updateProductInCart(new CartPojo(userId, prodId, pQty)); RequestDispatcher rd = request.getRequestDispatcher("userHome.jsp"); pw.println("<script>document.getElementById('message').innerHTML='" + status + "'</script>"); rd.include(request, response); } }

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html> <html> <head> <title>Cart Details</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous"> <link rel="stylesheet" href="mycss.css"> </head> <body style="background-color: #E6F9E6;"> <jsp:include page="header.jsp" /> <div class="text-center h3 m-3 text-primary">Cart Items</div> <div class="container"> <table class="table table-hover"> <thead> <tr> <th>Picture</th> <th>Products</th> <th>Price</th> <th>Quantity</th> <th>Add</th> <th>Remove</th> <th>Amount</th> </tr> </thead> <tbody> <% /* Java Code */ %> <tr> <td><img src="./ShowImageServlet?pid=<%=/* Java Code */%>" style="width: 50px; height: 50px;"></td> <td><%=/* Java Code */%></td> <td><%=/* Java Code */%></td> <td><form method="post" action="./UpdateToCartServlet"> <input type="number" name="pqty" value="<%=/* Java Code */%>" style="max-width: 70px;" min="0"><input type="hidden" name="pid" value="<%=/* Java Code */%>"><input type="submit" name="Update" value="Update" style="max-width: 80px;"> </form></td> <td><a href="CartDetailServlet?add=1&uid=<%=/* Java Code */%>&pid=<%=/* Java Code */%>&avail=<%=/* Java Code */%>&qty=<%=/* Java Code */%>"><i class="fa fa-plus"></i></a></td> <td><a href="CartDetailServlet?add=0&uid=<%=/* Java Code */%>&pid=<%=/* Java Code */%>&avail=<%=/* Java Code */%>&qty=<%=/* Java Code */%>"><i class="fa fa-minus"></i></a></td> <td><%=/* Java Code */%></td> </tr> <% } } %> <tr style="background-color: grey; color: white;"> <td colspan="6" style="text-align: center;">Total Amount to Pay (in Rupees)</td> <td><%=/* Java Code */%></td> </tr> <% /* Java Code */ { %> <tr style="background-color: grey; color: white;"> <td colspan="4" style="text-align: center;"> <td><form method="post"> <button formaction="UserHomeServlet" style="background-color: black; color: white;">Cancel</button> </form></td> <td colspan="2" align="center"><form method="post"> <button style="background-color: blue; color: white;" formaction="payment.jsp?amount=<%=/* Java Code */%>">Pay Now</button> </form></td> </tr> <% } %> </tbody> </table> </div> <!-- ENd of Product Items List --> <%@ include file="footer.jsp"%> </body> </html>


<% } %> <%@ include file="footer.jsp"%>

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@page import="in.gadgethub.dao.impl.*,in.gadgethub.pojo.*,in.gadgethub.utility.*,in.gadgethub.dao.*,java.util.*,javax.servlet.ServletOutputStream.*,java.io.*"%> <!DOCTYPE html> <html> <head> <title><%=AppInfo.appName%> Application</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous"> <link rel="stylesheet" href="mycss.css"> </head> <body style="background-color: #E6F9E6;"> <jsp:include page="header.jsp" /> <% if (request.getAttribute("message") != null) { %> <div class="text-center h3 text-primary m-3"><%=request.getAttribute("message")%></div> <% } %> <!-- <script>document.getElementById('mycart').innerHTML='<i data-count="20" class="fa fa-shopping-cart fa-3x icon-white badge" style="background-color:#333;margin:0px;padding:0px; margin-top:5px;"></i>'</script> --> <!-- Start of Product Items List --> <div class="container"> <div class="row text-center"> <% Map<String, Integer> mapList = (HashMap) request.getAttribute("map"); String userName = (String) request.getAttribute("userName"); List<ProductPojo> prodList = (ArrayList<ProductPojo>) request.getAttribute("products"); for (ProductPojo product : prodList) { int cartQty = mapList.get(product.getProdId()); %> <div class="col-sm-4"> <div class="thumbnail mt-3 mb-3"> <img src="./ShowImageServlet?pid=<%=product.getProdId()%>" alt="Product" style="height: 150px; max-width: 180px" class="mt-3"> <p class="productname"><%=product.getProdName()%> </p> <% String description = product.getProdInfo(); description = description.substring(0, Math.min(100, description.length())); %> <p class="productinfo"><%=description %>..</p> <p class="price"> Rs <%=product.getProdPrice()%> </p> <form method="post"> <%if(cartQty==0){%> <button type="submit" formaction="./AddToCartServlet?uid=<%=userName%>&pid=<%=product.getProdId()%>&pqty=1" class="btn btn-warning">Add to Cart</button> &nbsp;&nbsp;&nbsp; <button type="submit" formaction="./AddToCartServlet?uid=<%=userName%>&pid=<%=product.getProdId()%>&pqty=1&action=buy" formaction="cartDetails.jsp" class="btn btn-primary">Buy Now</button> <% }else{ %> <button type="submit" formaction="./AddToCartServlet?uid=<%=userName%>&pid=<%=product.getProdId()%>&pqty=0" class="btn btn-danger">Remove From Cart</button> &nbsp;&nbsp;&nbsp; <button type="submit" formaction="cartDetails.jsp" class="btn btn-success">Checkout</button> <% } %>

name="search" placeholder="Search Items" required />

} else { %> <li class="nav-item"><a class="nav-link" href="./CartDetailServlet" style="margin: 0px; padding: 0px;" id="mycart"><i data-count="<%=notf%>" class="fa fa-shopping-cart fa-3x icon-white badge" style="background-color: #333; margin: 0px; padding: 0px; padding-bottom: 0px; padding-top: 5px;"> </i></a></li> <% } %> <li class="nav-item"><a class="nav-link" href="./OrderServlet">Orders</a></li> <li class="nav-item"><a class="nav-link" href="./UserProfileServlet">Profile</a></li> <li class="nav-item"><a class="nav-link" href="./LogoutServlet">Logout</a></li> </ul> </div> </div> </nav> <% }else {%> <nav class="navbar navbar-expand-lg navbar-custom"> <div class="container-fluid"> <a class="navbar-brand" href="./AdminViewServlet"> <%=AppInfo.appName%> </a> <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button> <div class="collapse navbar-collapse" id="navbarNav"> <ul class="navbar-nav ms-auto"> <li class="nav-item"> <a class="nav-link" href="./AdminViewServlet">Products</a> </li> <li class="nav-item dropdown"> <jsp:include page="category.jsp" /> </li> <li class="nav-item"><a class="nav-link" href="./AdminStockServlet">Stock</a></li> <li class="nav-item"><a class="nav-link" href="./ShippedItemServlet">Shipped</a></li> <li class="nav-item"><a class="nav-link" href="./UnshippedItemServlet">Orders</a></li> <li class="nav-item dropdown"> <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false"> Update Item </a> <ul class="dropdown-menu" aria-labelledby="navbarDropdown"> <li><a href="addProduct.jsp" class="dropdown-item">Add Product</a></li> <li><a href="removeProduct.jsp" class="dropdown-item">Remove Product</a></li> <li><a href="updateProductById.jsp" class="dropdown-item">Update Product</a></li> </ul> </li> <li class="nav-item"> <a class="nav-link" href="./LogoutServlet">Logout</a> </li> </ul> </div> </div> </nav> <%} %> <!-- End of Navigation Bar --> <!--Company Header Starting --> <div class="container-fluid text-center bg-warning mt-0 p-3" style="--bs-bg-opacity: 0.5" > <h2><%=AppInfo.appName%></h2> <h6>We specialize in Electronics</h6> <form class="form-inline" action="LandingServlet" method="get"> <div class="input-group"> <input type="text" class="form-control"

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@page import="in.gadgethub.dao.impl.*,in.gadgethub.dao.*,in.gadgethub.utility.*" %> <!DOCTYPE html> <html> <head> <title>Logout Header</title> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" /> <link rel="stylesheet" href="mycss.css" /> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" /> </head> <body style="background-color: #e6f9e6"> <% String userType = (String) session.getAttribute("userType"); if (userType == null) { //GUEST %> <!-- Starting Navigation Bar --> <nav class="navbar navbar-expand-lg navbar-custom"> <div class="container-fluid"> <a class="navbar-brand" href="LandingServlet"> <%=AppInfo.appName%> </a> <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation" > <span class="navbar-toggler-icon"></span> </button> <div class="collapse navbar-collapse" id="navbarNav"> <ul class="navbar-nav ms-auto"> <!--Category JSP file--> <jsp:include page="category.jsp" /> <li class="nav-item"> <a class="nav-link" href="./LandingServlet">Products</a> </li> <li class="nav-item"> <a class="nav-link" href="login.jsp">Login</a> </li> <li class="nav-item"> <a class="nav-link" href="register.jsp">Register</a> </li> </ul> </div> </div> </nav> <% } else if (userType.equalsIgnoreCase("Customer")) { String userName = (String) request.getAttribute("userName"); CartDAOImpl cartDao = new CartDAOImpl(); int notf = cartDao.getAllCartItems(userName).size(); %> <nav class="navbar navbar-expand-lg navbar-custom"> <div class="container-fluid"> <a class="navbar-brand" href="UserHomeServlet"> <%=AppInfo.appName%> </a> <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button> <div class="collapse navbar-collapse" id="navbarNav"> <ul class="navbar-nav ms-auto"> <!--Category JSP file--> <jsp:include page="category.jsp" /> <li class="nav-item"> <a href="./UserHomeServlet" class="nav-link">Products</a> </li> <% if (notf == 0) { %> <li class="nav-item"><a class="nav-link" href="./CartDetailServlet"><span class="glyphiconglyphicon-shopping-cart"></span>Cart </a></li> <%

Repost from SCALive
🚀 New Batch Alert! Java Interview Bootcamp with Java 8 📅 Start Date: 18th Dec ⏰ Time: 9:30 PM 💻 Mode: Pure Online 👨‍🏫 Tr
🚀 New Batch Alert! Java Interview Bootcamp with Java 8 📅 Start Date: 18th Dec ⏰ Time: 9:30 PM 💻 Mode: Pure Online 👨‍🏫 Trainer: Sachin Sir 💡 Don’t miss this opportunity to level up your Java skills! 📩 Register now and get ready to ace your interviews! Registratin link : https://us02web.zoom.us/meeting/register/tZwkf-6qqTsoE9Lit8SU-BZaysw_uqzz6eSe Regards Team SCA