?? order.jsp
字號:
<%@ page language="java" contentType="text/html;charset=GB2312"%>
<jsp:useBean class="wdm.BookBean" id="bookinfo" scope="page"></jsp:useBean>
<jsp:useBean class="wdm.OrderBean" id="orderBean" scope="page"></jsp:useBean>
<%
response.setHeader("Pragma", "No-cache");
response.setHeader("Cache-Control", "no-cache");
response.setDateHeader("Expires", 0);
%>
<HTML>
<HEAD>
<META http-equiv="Content-Style-Type" content="text/css">
<TITLE>填寫訂單</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<%
if ("send".equals(request.getParameter("send"))) {
orderBean.setUserID((String) session.getValue("memberID"));
String str = request.getParameter("receivername");
orderBean.setReceiverName(str == null ? "" : str);
str = request.getParameter("orderprice");
orderBean.setOderprice(str == null ? "0" : str);
str = request.getParameter("address");
orderBean.setReceiverAddress(str == null ? "" : str);
str = request.getParameter("postcode");
orderBean.setReceiverZip(str == null ? "" : str);
str = request.getParameter("bookinfo");
orderBean.setBookinfo(str == null ? "" : str);
str = request.getParameter("orderrem");
orderBean.setOrderRem(str == null ? "" : str);
int orderID = orderBean.getOrderID();
if (orderID > 0) { /*清空Cookie(購物車)信息*/
Cookie[] cookies = request.getCookies();
for (int i = 0; i < cookies.length; i++) {
String isbn = cookies[i].getName();
if (isbn.startsWith("ISBN") && isbn.length() == 17) {
Cookie c = new Cookie(isbn, "0");
c.setMaxAge(0);//設定Cookie立即失效
response.addCookie(c);
}
}
%>
<p align="center">
訂購成功!
</p>
<p align="center">
訂單號:
<%=orderID%>
</p>
<p align="center">
<A href="booklist.jsp">返回首頁 </A>
</p>
<%
} else {
out.print("訂購失敗\n");
}
}
else {
float price = 0;
String bookInfo = "";
%>
<FORM method="post" name="frm">
<TABLE border="1" width="100%" cellspacing="0" bordercolor="#9999FF">
<TR>
<TD width="258">
ISBN
</TD>
<TD width="269">
書名
</TD>
<TD width="50">
單價
</TD>
<TD width="75">
數量
</TD>
<TD width="48">
價格
</TD>
</TR>
<%
/*讀取購物車信息*/
Cookie[] cookies = request.getCookies();
for (int i = 0; i < cookies.length; i++) {
String isbn = cookies[i].getName();
String num = cookies[i].getValue();
if (isbn.startsWith("ISBN") && isbn.length() == 17) {
bookinfo.setBookISBN(isbn.substring(4, 17));
Float bookPrice = new Float(bookinfo.getPrice());
%>
<TR>
<TD width="258">
<%=bookinfo.getBookISBN()%>
</TD>
<TD width="269">
<A href="bookinfo.jsp?isbn=<%=bookinfo.getBookISBN()%>"><%=bookinfo.getBookName()%>
</A>
</TD>
<TD width="50">
<%=bookPrice%>
</TD>
<TD width="75">
<INPUT size="5" type="text" maxlength="5" value="<%=num%>"
name="num" readonly>
</TD>
<TD width="48">
<%=bookPrice.floatValue()
* java.lang.Integer.parseInt(num)%>
</TD>
</TR>
<%
price += bookPrice.floatValue()
* java.lang.Integer.parseInt(num);
bookInfo += bookinfo.getBookISBN() + "=" + num + ";";
}
}
%>
</TABLE>
<p>
</p>
<table width="100%" border="0">
<tr>
<td width="34%">
</td>
<td width="41%">
<div align="center">
<A href="shoppingcart.jsp">修改圖書訂單 </A>
</div>
</td>
<td width="25%">
</td>
</tr>
</table>
<p>
<font color="#0000FF">如以上信息無誤,請填寫以下信息并按提交按鈕提交訂單,完成網上訂書:</font>
</p>
<table width="100%" border="0">
<tr>
<td width="17%">
<font color="#0000FF">收書人姓名</font>
</td>
<td width="83%">
<input type="text" name="receivername" size="10" maxlength="10">
</td>
</tr>
<tr>
<td width="17%">
<font color="#0000FF">訂單總金額 </font>
</td>
<td width="83%">
<input type="text" name="orderprice" size="10" value="<%=price%>"
readonly>
</td>
</tr>
<tr>
<td width="17%">
<font color="#0000FF">發送地址 </font>
</td>
<td width="83%">
<input type="text" name="address" size="60" maxlength="60">
</td>
</tr>
<tr>
<td width="17%">
<font color="#0000FF">郵編 </font>
</td>
<td width="83%">
<input type="text" name="postcode" size="6" maxlength="6">
</td>
</tr>
<tr>
<td width="17%">
<font color="#0000FF">備注 </font>
</td>
<td width="83%">
<textarea name="orderrem" cols="60" rows="6"></textarea>
</td>
</tr>
<tr>
<td width="17%">
<font color="#0000FF"></font>
</td>
<td width="83%">
<input type="submit" name="Submit" value="提交訂單">
<input type="hidden" name="send" value="send">
<input type="hidden" name="bookinfo" value="<%=bookInfo%>">
</td>
</tr>
</table>
</FORM>
<%
}
%>
</BODY>
</HTML>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -