purchase.jsp

来自「Easy_Buy是一个在线销售系统」· JSP 代码 · 共 37 行

JSP
37
字号
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<jsp:useBean id="pool" scope="application" class="PoolBean"/>
<jsp:useBean id="list" scope="session" class="ProductListBean"/>
<jsp:setProperty name="list" property="*"/>
<% 
	Product prod=list.getProduct();
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>

<body>
<center>
<% 
if(session.getValue("username")==null)
{
	response.sendRedirect("shoppingError.jsp");
}
else
{
	String user=(String)session.getValue("username");
	int p_id=prod.productID;
		
	Connection conn=pool.getConnection();
	Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);  
	String sql1="insert into cart(username,productID) values ('"+user+"',"+p_id+")"; 
	stmt.executeUpdate(sql1);
	stmt.close();
	pool.releaseConnection(conn);
	response.sendRedirect("purchaseOK.jsp");
}
%>
</center>
</body>
</html>

⌨️ 快捷键说明

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