__eshop.java
上传用户:xjrzjk
上传日期:2022-07-31
资源大小:1585k
文件大小:15k
- /* compiled from JSP: /eshop.jsp
- *
- * This code was automatically generated at 9:33:17 on 2004-5-7
- * by weblogic.servlet.jsp.Jsp2Java -- do not edit.
- */
- package jsp_servlet;
- import java.io.*;
- import java.util.*;
- import javax.servlet.*;
- import javax.servlet.http.*;
- import javax.servlet.jsp.*;
- import javax.servlet.jsp.tagext.*;
- // User imports
- import java.sql.*; //[ /eshop.jsp; Line: 2]
import java.text.DecimalFormat; //[ /eshop.jsp; Line: 3]
- // built-in init parameters:
- // boolean _verbose -- wants debugging
- // Well-known variables:
- // JspWriter out -- to write to the browser
- // HttpServletRequest request -- the request object.
- // HttpServletResponse response -- the response object.
- // PageContext pageContext -- the page context for this JSP
- // HttpSession session -- the session object for the client (if any)
- // ServletContext application -- The servlet (application) context
- // ServletConfig config -- The ServletConfig for this JSP
- // Object page -- the instance of this page's implementation class (i.e., 'this')
- /**
- * This code was automatically generated at 9:33:17 on 2004-5-7
- * by weblogic.servlet.jsp.Jsp2Java -- do not edit.
- *
- * Copyright (c) 2004 by BEA Systems, Inc. All Rights Reserved.
- */
- public final class __eshop
- extends
- weblogic.servlet.jsp.JspBase
- implements weblogic.servlet.jsp.StaleIndicator
- {
-
- //[ /eshop.jsp; Line: 4]
private void puttoShopBag(String cpbm, String productList){ //[ /eshop.jsp; Line: 5]
if (productList == null){ //[ /eshop.jsp; Line: 6]
productList = "'" + cpbm + "'"; //[ /eshop.jsp; Line: 7]
}else if (productList.lastIndexOf(cpbm)<0){ //[ /eshop.jsp; Line: 8]
productList = productList + ",'" + cpbm + "'"; //[ /eshop.jsp; Line: 9]
} //[ /eshop.jsp; Line: 10]
} //[ /eshop.jsp; Line: 11]
//[ /eshop.jsp; Line: 12]
// StaleIndicator interface
public boolean _isStale() {
weblogic.servlet.jsp.StaleChecker sci =(weblogic.servlet.jsp.StaleChecker)(getServletConfig().getServletContext());
java.io.File f = null;
long lastModWhenBuilt = 0L;
if (sci.isResourceStale("/eshop.jsp", 1083893574000L, "WebLogic Server 7.0 Thu Jun 20 11:47:11 PDT 2002 190955 ")) return true;
return false;
}
public static boolean _staticIsStale(weblogic.servlet.jsp.StaleChecker sci) {
java.io.File f = null;
long lastModWhenBuilt = 0L;
if (sci.isResourceStale("/eshop.jsp", 1083893574000L, "WebLogic Server 7.0 Thu Jun 20 11:47:11 PDT 2002 190955 ")) return true;
return false;
}
-
- public void _jspService(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOException, javax.servlet.ServletException
- {
-
- // declare and set well-known variables:
- javax.servlet.ServletConfig config = getServletConfig();
- javax.servlet.ServletContext application = config.getServletContext();
- javax.servlet.jsp.tagext.Tag _activeTag = null;
- // variables for Tag extension protocol
- Object page = this;
- javax.servlet.jsp.JspWriter out;
- javax.servlet.jsp.PageContext pageContext =
javax.servlet.jsp.JspFactory.getDefaultFactory().getPageContext(this, request, response, null, true, 8192, true);
- response.setHeader("Content-Type", "text/html; charset=GBK");
out = pageContext.getOut();
JspWriter _originalOut = out;
- javax.servlet.http.HttpSession session = request.getSession(true);
-
-
- try { // error page try block
response.setContentType("text/html; charset=GBK");
out.print("rn");
out.print("rn");
out.print("rn");
out.print("rn");
//[ /eshop.jsp; Line: 13]
try{ //[ /eshop.jsp; Line: 14]
String[] arrayProduct = request.getParameterValues("cpbm"); //[ /eshop.jsp; Line: 15]
String strCheck = ""; //[ /eshop.jsp; Line: 16]
//[ /eshop.jsp; Line: 17]
System.out.println("选购商品的产品编码长度为:" + arrayProduct.length); //[ /eshop.jsp; Line: 18]
//[ /eshop.jsp; Line: 19]
if (arrayProduct.length == 0){ //[ /eshop.jsp; Line: 20]
strCheck = "no"; //[ /eshop.jsp; Line: 21]
} //[ /eshop.jsp; Line: 22]
String productList = (String)request.getSession(true).getAttribute("productList"); //[ /eshop.jsp; Line: 23]
//[ /eshop.jsp; Line: 24]
System.out.println("选购商品的产品编码列表为:" + productList); //[ /eshop.jsp; Line: 25]
//System.out.println("********" + (productList == null)); //[ /eshop.jsp; Line: 26]
//[ /eshop.jsp; Line: 27]
for (int i=0; i<arrayProduct.length; i++){ //[ /eshop.jsp; Line: 28]
System.out.println("选购商品的产品编码列表变化为:" + productList); //[ /eshop.jsp; Line: 29]
this.puttoShopBag(arrayProduct[i],productList); //[ /eshop.jsp; Line: 30]
} //[ /eshop.jsp; Line: 31]
request.getSession(true).setAttribute("productList", productList); //[ /eshop.jsp; Line: 32]
//[ /eshop.jsp; Line: 33]
String head = "以下是您所选购的物品清单"; //[ /eshop.jsp; Line: 34]
productList = (String)request.getSession(true).getAttribute("productList"); //[ /eshop.jsp; Line: 35]
if (productList.length() == 0){ //[ /eshop.jsp; Line: 36]
response.sendRedirect("nothing.jsp"); //[ /eshop.jsp; Line: 37]
return; //[ /eshop.jsp; Line: 38]
} //[ /eshop.jsp; Line: 39]
String strMySelf = request.getParameter("MySelf"); //[ /eshop.jsp; Line: 40]
if (strMySelf.equals("Yes")){ //[ /eshop.jsp; Line: 41]
productList = ""; //[ /eshop.jsp; Line: 42]
String[] arrayCpbm = request.getParameterValues("cpbm"); //[ /eshop.jsp; Line: 43]
for (int i=0;i<arrayCpbm.length;i++){ //[ /eshop.jsp; Line: 44]
this.puttoShopBag(arrayCpbm[i],productList); //[ /eshop.jsp; Line: 45]
} //[ /eshop.jsp; Line: 46]
request.getSession(true).setAttribute("productList", productList); //[ /eshop.jsp; Line: 47]
} //[ /eshop.jsp; Line: 48]
if (productList.length() == 0){ //[ /eshop.jsp; Line: 49]
response.sendRedirect("nothing.jsp"); //[ /eshop.jsp; Line: 50]
return; //[ /eshop.jsp; Line: 51]
} //[ /eshop.jsp; Line: 52]
//数据库连接 //[ /eshop.jsp; Line: 53]
Class.forName("oracle.jdbc.driver.OracleDriver"); //[ /eshop.jsp; Line: 54]
String strUrl = "jdbc:oracle:thin:@slight:1521:LOCAL"; //[ /eshop.jsp; Line: 55]
String strUser = "eshop"; //[ /eshop.jsp; Line: 56]
String strPassword = "eshop"; //[ /eshop.jsp; Line: 57]
Connection con = DriverManager.getConnection(strUrl, strUser, strPassword); //[ /eshop.jsp; Line: 58]
Statement st = con.createStatement(); //[ /eshop.jsp; Line: 59]
String sql = "select * from product where product_id in (" + productList +")"; //[ /eshop.jsp; Line: 60]
ResultSet rs = st.executeQuery(sql); //[ /eshop.jsp; Line: 61]
out.print("rn<html>rn<head>rn<title>rn以下是您所选购的物品清单rn</title>rn<link rel="stylesheet" type="text/css" href="style.css">rn</head>rn<script language="Javascript">rn//函数名:fucCheckNUMrn//功能介绍:检查是否为数字rn//参数说明:要检查的数字rn//返回值:1为是数字,0为不是数字rnfunction fucCheckNUM(NUM)rn{rntvar i,j,strTemp;rntstrTemp="0123456789";rntif ( NUM.length== 0)rnttreturn 0rntfor (i=0;i<NUM.length;i++)rnt{rnttj=strTemp.indexOf(NUM.charAt(i));rnttif (j==-1)rntt{rntt//说明有字符不是数字rntttreturn 0;rntt}rnt}rnt//说明是数字rntreturn 1;rn}rnrnfunction clean()rn {rn window.location.href="clear.asp"rn }rn</script>rn<SCRIPT language=javascript id=clientEventHandlersJS>rn<!--rnfunction form1_onsubmit()rn{rnnewprice="Q_" & rs("Product_Id")rn tif ((fucCheckNUM(document.FORM1.newprice.value)==0) )rnt{talert ("会员价有非法字符,请填写正确会员价。");rnttdocument.FORM1.newprice.focus();rnttreturn false;rnt}rn//-->rn}rn</SCRIPT>rn<body topmargin="5">rnrn<div align="center">rnrn<table width="80%" border="0" cellspacing="0">rn <tr>rn <td width="80%" valign="top">rn <p align="center">rn<font col");
out.print("or="#FF0000" >");
out.print(String.valueOf(head)); //[ /eshop.jsp; Line: 120]
out.print("</font></p>rn <!--webbot BOT="GeneratedScript" PREVIEW=" " startspan --><script Language="JavaScript"><!--rnfunction FrontPage_Form1_Validator(theForm)rn{rnrn var checkOK = "0123456789-";rn var checkStr = theForm.");
out.print(String.valueOf("Q_" + rs.getString("Product_Id"))); //[ /eshop.jsp; Line: 126]
out.print(".value;rn var allValid = true;rn var decPoints = 0;rn var allNum = "";rn for (i = 0; i < checkStr.length; i++)rn {rn ch = checkStr.charAt(i);rn for (j = 0; j < checkOK.length; j++)rn if (ch == checkOK.charAt(j))rn break;rn if (j == checkOK.length)rn {rn allValid = false;rn break;rn }rn allNum += ch;rn }rn if (!allValid)rn {rn alert("在 请输入正确的商品数量! 域中,只能输入 数字 个字符。");rn theForm.");
out.print(String.valueOf("Q_" + rs.getString("Product_Id"))); //[ /eshop.jsp; Line: 146]
out.print(".focus();rn return (false);rn }rn return (true);rn}rn//-->rn</script>rnrn<form Action="eshop.jsp" Method="POST" onsubmit="return FrontPage_Form1_Validator(this)" name="FrontPage_Form1">rn<input type="hidden" name="MySelf" value="Yes">rn<table border="0" cellspacing="1" width="550" class=main bgcolor="#000000">rn <tr bgcolor="#006699">rn <td align="center" width="82" height="22" bgcolor="#006699"><font color="#EEEEEE">商品编号</font></td>rn <td align="center" width="170" height="22" bgcolor="#006699"><font color="#EEEEEE">商品名称</font></td>rn <td align="center" width="76" height="22" bgcolor="#006699"><font color="#EEEEEE">商品价格</font></td>rn <td align="center" width="76" height="22" bgcolor="#006699"><font color="#EEEEEE">商品数量</font></td>rn <td align="center" width="60" height="22" bgcolor="#006699"><font color="#EEEEEE">购买</font></td>rn <td align="center" width="72" height="22" bgcolor="#006699"><font color="#EEEEEE">总价</font></td>rn </tr");
out.print(">rn");
//[ /eshop.jsp; Line: 165]
double dbSum = 0; //[ /eshop.jsp; Line: 166]
DecimalFormat df = new DecimalFormat("0.00"); //[ /eshop.jsp; Line: 167]
while(rs.next()){ //[ /eshop.jsp; Line: 168]
int Quatity = Integer.parseInt(request.getParameter("Q_" + rs.getString("product_id"))); //[ /eshop.jsp; Line: 169]
if (Quatity <=0){ //[ /eshop.jsp; Line: 170]
Quatity = 1; //[ /eshop.jsp; Line: 171]
} //[ /eshop.jsp; Line: 172]
request.getSession(true).setAttribute("product_id", String.valueOf(Quatity)); //[ /eshop.jsp; Line: 173]
dbSum = dbSum + rs.getDouble("p_newprice") * Quatity; //[ /eshop.jsp; Line: 174]
out.print("rn <tr>rn <td align="center" width="82" bgcolor="#EEEEEE">");
out.print(String.valueOf(rs.getString("Product_ID"))); //[ /eshop.jsp; Line: 177]
out.print("</td>rn <td align="center" width="170" bgcolor="#EEEEEE">");
out.print(String.valueOf(rs.getString("Product_Name"))); //[ /eshop.jsp; Line: 178]
out.print("</td>rn <td align="center" width="76" bgcolor="#EEEEEE">");
out.print(String.valueOf(df.format(rs.getDouble("P_NewPrice")))); //[ /eshop.jsp; Line: 179]
out.print("</td>rn <td align="center" width="76" bgcolor="#EEEEEE"><input Name="");
out.print(String.valueOf("Q_" + rs.getString("Product_Id"))); //[ /eshop.jsp; Line: 180]
out.print("" Value="");
out.print(String.valueOf(Quatity)); //[ /eshop.jsp; Line: 180]
out.print("" Size="3"></td>rn <td Align="center" width="60" bgcolor="#EEEEEE"><input Type="CheckBox" Name="cpbm" Value="");
out.print(String.valueOf(rs.getString("Product_Id"))); //[ /eshop.jsp; Line: 181]
out.print("" Checked></td>rn <td Align="center" width="72" bgcolor="#EEEEEE">");
out.print(String.valueOf(df.format(rs.getDouble("P_NewPrice")*Quatity))); //[ /eshop.jsp; Line: 182]
out.print("元</td>rn </tr>rn");
//[ /eshop.jsp; Line: 184]
} //[ /eshop.jsp; Line: 185]
out.print("rn <tr>rn <td Align="Right" ColSpan="6" width="546" bgcolor="#EEEEEE">rn <font Color="Red">总价格=人民币 ");
out.print(String.valueOf(df.format(dbSum))); //[ /eshop.jsp; Line: 189]
out.print(".00元</font>rn </td>rn </tr>rn </table>rn <blockquote>rn <input Type="submit" Value="更改数量" name="B1" style="font-size: 9pt"> rn <input type="button" value="继续购物" name="B2" onclick="window.close();" style="font-size: 9pt"> rn <input type="button" value="订单取消" name="B3" OnClick="clean()" style="font-size: 9pt"> rn <input type="button" value="去收银台" onClick="window.open('ment.asp',window.close(), 'Sample', 'toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=yes,width=610,height=600,left=100,top=100')" name="b4"> <p align="center"><font color="#FF0000">注意:改变“商品数量需按“更改数量”</font>rn </blockquote>rn </form>rn </td>rn</tr>rn</table>rnrn</div>rn</body>rn</html>rn");
//[ /eshop.jsp; Line: 207]
}catch(Exception e){ //[ /eshop.jsp; Line: 208]
//错误处理 //[ /eshop.jsp; Line: 209]
throw (e); //[ /eshop.jsp; Line: 210]
} //[ /eshop.jsp; Line: 211]
} catch (Throwable __ee) {
while (out != null && out != _originalOut) out = pageContext.popBody();
((weblogic.servlet.jsp.PageContextImpl)pageContext).handlePageException((Throwable)__ee);
}
- //before final close brace...
- }
-
-
- }