?? __eshop.java
字號(hào):
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("選購(gòu)商品的產(chǎn)品編碼長(zhǎng)度為:" + 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("選購(gòu)商品的產(chǎn)品編碼列表為:" + 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("選購(gòu)商品的產(chǎn)品編碼列表變化為:" + 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 = "以下是您所選購(gòu)的物品清單"; //[ /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] //數(shù)據(jù)庫(kù)連接 //[ /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("\r\n<html>\r\n<head>\r\n<title>\r\n以下是您所選購(gòu)的物品清單\r\n</title>\r\n<link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\">\r\n</head>\r\n<script language=\"Javascript\">\r\n//函數(shù)名:fucCheckNUM\r\n//功能介紹:檢查是否為數(shù)字\r\n//參數(shù)說(shuō)明:要檢查的數(shù)字\r\n//返回值:1為是數(shù)字,0為不是數(shù)字\r\nfunction fucCheckNUM(NUM)\r\n{\r\n\tvar i,j,strTemp;\r\n\tstrTemp=\"0123456789\";\r\n\tif ( NUM.length== 0)\r\n\t\treturn 0\r\n\tfor (i=0;i<NUM.length;i++)\r\n\t{\r\n\t\tj=strTemp.indexOf(NUM.charAt(i));\r\n\t\tif (j==-1)\r\n\t\t{\r\n\t\t//說(shuō)明有字符不是數(shù)字\r\n\t\t\treturn 0;\r\n\t\t}\r\n\t}\r\n\t//說(shuō)明是數(shù)字\r\n\treturn 1;\r\n}\r\n\r\nfunction clean()\r\n {\r\n window.location.href=\"clear.asp\"\r\n }\r\n</script>\r\n<SCRIPT language=javascript id=clientEventHandlersJS>\r\n<!--\r\nfunction form1_onsubmit()\r\n{\r\nnewprice=\"Q_\" & rs(\"Product_Id\")\r\n \tif ((fucCheckNUM(document.FORM1.newprice.value)==0) )\r\n\t{\talert (\"會(huì)員價(jià)有非法字符,請(qǐng)?zhí)顚?xiě)正確會(huì)員價(jià)。\");\r\n\t\tdocument.FORM1.newprice.focus();\r\n\t\treturn false;\r\n\t}\r\n//-->\r\n}\r\n</SCRIPT>\r\n<body topmargin=\"5\">\r\n\r\n<div align=\"center\">\r\n\r\n<table width=\"80%\" border=\"0\" cellspacing=\"0\">\r\n <tr>\r\n <td width=\"80%\" valign=\"top\">\r\n <p align=\"center\">\r\n<font col"); out.print("or=\"#FF0000\" >"); out.print(String.valueOf(head)); //[ /eshop.jsp; Line: 120] out.print("</font></p>\r\n <!--webbot BOT=\"GeneratedScript\" PREVIEW=\" \" startspan --><script Language=\"JavaScript\"><!--\r\nfunction FrontPage_Form1_Validator(theForm)\r\n{\r\n\r\n var checkOK = \"0123456789-\";\r\n var checkStr = theForm."); out.print(String.valueOf("Q_" + rs.getString("Product_Id"))); //[ /eshop.jsp; Line: 126] out.print(".value;\r\n var allValid = true;\r\n var decPoints = 0;\r\n var allNum = \"\";\r\n for (i = 0; i < checkStr.length; i++)\r\n {\r\n ch = checkStr.charAt(i);\r\n for (j = 0; j < checkOK.length; j++)\r\n if (ch == checkOK.charAt(j))\r\n break;\r\n if (j == checkOK.length)\r\n {\r\n allValid = false;\r\n break;\r\n }\r\n allNum += ch;\r\n }\r\n if (!allValid)\r\n {\r\n alert(\"在 請(qǐng)輸入正確的商品數(shù)量! 域中,只能輸入 數(shù)字 個(gè)字符。\");\r\n theForm."); out.print(String.valueOf("Q_" + rs.getString("Product_Id"))); //[ /eshop.jsp; Line: 146] out.print(".focus();\r\n return (false);\r\n }\r\n return (true);\r\n}\r\n//-->\r\n</script>\r\n\r\n<form Action=\"eshop.jsp\" Method=\"POST\" onsubmit=\"return FrontPage_Form1_Validator(this)\" name=\"FrontPage_Form1\">\r\n<input type=\"hidden\" name=\"MySelf\" value=\"Yes\">\r\n<table border=\"0\" cellspacing=\"1\" width=\"550\" class=main bgcolor=\"#000000\">\r\n <tr bgcolor=\"#006699\">\r\n <td align=\"center\" width=\"82\" height=\"22\" bgcolor=\"#006699\"><font color=\"#EEEEEE\">商品編號(hào)</font></td>\r\n <td align=\"center\" width=\"170\" height=\"22\" bgcolor=\"#006699\"><font color=\"#EEEEEE\">商品名稱</font></td>\r\n <td align=\"center\" width=\"76\" height=\"22\" bgcolor=\"#006699\"><font color=\"#EEEEEE\">商品價(jià)格</font></td>\r\n <td align=\"center\" width=\"76\" height=\"22\" bgcolor=\"#006699\"><font color=\"#EEEEEE\">商品數(shù)量</font></td>\r\n <td align=\"center\" width=\"60\" height=\"22\" bgcolor=\"#006699\"><font color=\"#EEEEEE\">購(gòu)買(mǎi)</font></td>\r\n <td align=\"center\" width=\"72\" height=\"22\" bgcolor=\"#006699\"><font color=\"#EEEEEE\">總價(jià)</font></td>\r\n </tr"); out.print(">\r\n"); //[ /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("\r\n <tr>\r\n <td align=\"center\" width=\"82\" bgcolor=\"#EEEEEE\">"); out.print(String.valueOf(rs.getString("Product_ID"))); //[ /eshop.jsp; Line: 177] out.print("</td>\r\n <td align=\"center\" width=\"170\" bgcolor=\"#EEEEEE\">"); out.print(String.valueOf(rs.getString("Product_Name"))); //[ /eshop.jsp; Line: 178] out.print("</td>\r\n <td align=\"center\" width=\"76\" bgcolor=\"#EEEEEE\">"); out.print(String.valueOf(df.format(rs.getDouble("P_NewPrice")))); //[ /eshop.jsp; Line: 179] out.print("</td>\r\n <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>\r\n <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>\r\n <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>\r\n </tr>\r\n"); //[ /eshop.jsp; Line: 184] } //[ /eshop.jsp; Line: 185] out.print("\r\n <tr>\r\n <td Align=\"Right\" ColSpan=\"6\" width=\"546\" bgcolor=\"#EEEEEE\">\r\n <font Color=\"Red\">總價(jià)格=人民幣 "); out.print(String.valueOf(df.format(dbSum))); //[ /eshop.jsp; Line: 189] out.print(".00元</font>\r\n </td>\r\n </tr>\r\n </table>\r\n <blockquote>\r\n <input Type=\"submit\" Value=\"更改數(shù)量\" name=\"B1\" style=\"font-size: 9pt\"> \r\n <input type=\"button\" value=\"繼續(xù)購(gòu)物\" name=\"B2\" onclick=\"window.close();\" style=\"font-size: 9pt\"> \r\n <input type=\"button\" value=\"訂單取消\" name=\"B3\" OnClick=\"clean()\" style=\"font-size: 9pt\"> \r\n <input type=\"button\" value=\"去收銀臺(tái)\" 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\">注意:改變“商品數(shù)量需按“更改數(shù)量”</font>\r\n </blockquote>\r\n </form>\r\n </td>\r\n</tr>\r\n</table>\r\n\r\n</div>\r\n</body>\r\n</html>\r\n"); //[ /eshop.jsp; Line: 207] }catch(Exception e){ //[ /eshop.jsp; Line: 208] //錯(cuò)誤處理 //[ /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...
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -