求助,jsp上传商品信息就直接GG了
<%@ page language="java" import="java.util.*,java.text.*" pageEncoding="UTF-8"%><%@ page import="java.sql.*" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'raddItem.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<script type="text/javascript">
function setChange(obj){
var value=obj.value;
location.href="admin/product/raddItem.jsp?stagename="+value;
}
</script>
</head>
<body>
<jsp:useBean id="mybean" class="shoppingmanage.Manage"></jsp:useBean>
<%
//获取当前日期
SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String mynow= sdf.format(new java.util.Date());
//获取客户端数据
String cid=null;
String csname=request.getParameter("csname");
csname= new String(csname.getBytes("iso-8859-1"),"UTF-8");
String ptname=request.getParameter("ptname");
ptname= new String(ptname.getBytes("iso-8859-1"),"UTF-8");
String pprice=request.getParameter("pprice");
// String pimage=request.getParameter("pimage");
String pimage=(String)session.getAttribute("imageUrl");
// pimage=getServletContext().getRealPath("/")+"admin\\product\\productimage\\"+pimage;
int pnum=Integer.parseInt(request.getParameter("pnum"));
String pcontent=request.getParameter("pcontent");
pcontent= new String(pcontent.getBytes("iso-8859-1"), "utf-8");
//条件查询数据表
String sql="select * from ccategory where pname='"+session.getAttribute("pname")+"'and stagename='"+csname+"'";
ResultSet rs=mybean.select(sql);
if(rs.next()){
cid=rs.getString("id");
sql="insert into product values('"+csname+"','"+ptname+"','"+pprice+"','"+pimage+"','"+pcontent+"','','"+mynow+"',"+pnum+")";
mybean.insert(sql);
out.print("商品添加成功");
session.setAttribute("imageUrl", null);
out.print("<script> window.history.back()</script>");
}
else
out.print("商品添加不成功");
%>
</body>
</html>