当前位置:文档之家› JSP实现购物车功能

JSP实现购物车功能

<a href="shop_order.asp">确认购买</a></td>
</tr>
</table>
</center></div></td>
</tr>
<tr align="center">
<td width="610" height="1" colspan="5"><div align="center"><center>
bordercolorlight="#FFB468"
bordercolordark="#FFFFFF" bgcolor="#FFB468">
<tr>
<td width="100%"><div align="center"><center><p><a
href="javascript: document.forms[0].submit()">重新计费</a></td>
下面是我用JSP和数据库做的购物车的源程序:
//shop_cart.jsp
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page session="true" %>
<%@ page language="java" import="java.sql.*" %>
<td width="12%" height="8" align="left">定金比例</td>
<td width="17%" height="8" align="left">定金小计</td>
<td width="17%" height="8" align="left">删除</td>
</tr>
rs = bka.executeQuery(sql);
}
}
if (pareTo("clear")==0) {
sql="delete from shop_cart where cart_shop_id=" + shop_id + "
and cart_guest_id='" + guest_name + "'";
height="2">
<tr>
<td width="122" height="7"><div align="center"><center><table
border="1" cellpadding="2" cellspacing="0" width="100%"
bordercolorlight="#FFB468" bordercolordark="#FFFFFF"
action="shop_cart.jsp?action=update&product_type=<%=product_type%>&curp
age=<%=curpage%>">
<table border="0" cellpadding="0" cellspacing="0" width="610"
<tr>
<td width="100%"><div align="center"><center><p><a
href="shop_list.jsp?shop_id=<%=shop_id%>&product_type=<%=product_type%>
&curpage=<%=curpage%>">继续购物</a></td>
bgcolor="#FFB468">
<tr>
<td width="100%"><div
align="center"><center><p>购物车</td>
</tr>
</table>
</center></div></td>
<td width="122" height="7" style="border: medium"
curpage=1;
}else{
curpage=ng.Integer.parseInt(request.getParameter("curpagegetParameter("action")==null){
action="view";
}else{
action=request.getParameter("action");
}
//商品编号
if (request.getParameter("product_id")==null){
product_id=0;
}else{
product_id=ng.Integer.parseInt(request.getParameter("product_id"));
align="center"><div align="center"><center><table
border="1" cellpadding="2" cellspacing="0" width="100%"
bordercolorlight="#FFB468"
bordercolordark="#FFFFFF" bgcolor="#FFB468">
<table border="1" cellpadding="2" cellspacing="0" width="100%"
bgcolor="#FDFEE2" bordercolorlight="#FFB468"
bordercolordark="#FFFFFF" height="40">
<tr>
<td width="20%" height="8" align="left">商品名称</td>
<%=curpage%>">清空购物车</a></td>
</tr>
</table>
</center></div></td>
<td width="122" height="7" style="border: medium" align="center">
<div align="center"><center><table
sql="update shop_cart set cart_quantity=" + cart_quantity + "
where cart_shop_id=" + shop_id + " and cart_guest_id='" +
guest_name + "' and cart_product_id=" + product_id ;
<jsp:useBean id="bka" scope="page" class="shop.bka" />
<%
String product_type;
String action;
int product_id;
int curpage;
//商品类型
if (request.getParameter("product_type")==null){
+ shop_id + " and cart_guest_id='" + guest_name + "'
and cart_product_id=" + product_id ;
rs = bka.executeQuery(sql);
if (rs.next()){
int cart_quantity;
cart_quantity=ng.Integer.parseInt(rs.getString("cart_quantity"))+1;
product_type="all";
}else{
product_type=request.getParameter("product_type");
}
//页数和商品类型参数,可以在“继续购物”时返回到上次购物的页面
if (request.getParameter("curpage")==null){
}
int bbb;
bbb=1;
Integer num = new Integer(bbb);
//商店编号
session.putValue("shop_id",num);
相关主题