⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 shoppingcart.jsp

📁 《精通JSP编程 》源代码(赵强那本) 很有用的源代码
💻 JSP
字号:
<%@ page import="jnestore.javabeans.*" %>
<%@ page import="java.util.*" %>

<h3>Shopping Cart</h3>

Here are the items you have selected:<br>
  <table border=1>
    <tr> 
      <td>SKU code</td>
      <td>Product</td>
      <td>Description</td>
      <td>Price</td>
      <td>&nbsp;</td>
    </tr>
<%
  Hashtable shoppingCart = (Hashtable)session.getAttribute("shoppingcart");
  if(shoppingCart == null) {
  	shoppingCart = new Hashtable();
	session.setAttribute("shoppingcart", shoppingCart);
  }
  
  Enumeration e = shoppingCart.elements();
  float total = 0;
  while(e.hasMoreElements()) {
    ItemInfo item = (ItemInfo)e.nextElement(); 
    total += item.getPrice(); %>
    <tr>
      <td><%=item.getSku()%></td>
      <td><%=item.getName()%></td>
      <td><%=item.getDescription()%></td>
      <td>$<%=item.getPrice()%></td>
      <td><A HREF="<%=response.encodeURL("cart.jsp?operation=removeItem&sku=" + item.getSku())%>" onClick="return confirm('Are you sure you want to remove product <%=item.getSku()%>?');">[remove]</A></td>
    </tr>
  <% } %>
  
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>
        <b>Total:</b>
      </td>
      <td><b>$<%=total%></b></td>
      <td>&nbsp;</td>
    </tr>
  </table>
  
<BR><BR>
<A HREF="<%=response.encodeURL("cart.jsp?operation=removeAll")%>" onClick="return confirm('Are you sure you want to remove all products?');">empty shopping cart</A>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -