mybasket.jsp

来自「在网上书店买书」· JSP 代码 · 共 160 行

JSP
160
字号
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@page import="java.sql.*"%>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.Iterator" %>
<%@page import="Model.DataOperation"%>
<%@ page import="Model.Basket" %>
<%@ page import="Model.Book" %>
<%--
The taglib directive below imports the JSTL library. If you uncomment it,
you must also add the JSTL library to the project. The Add Library... action
on Libraries node in Projects view can be used to add the JSTL 1.1 library.
--%>
<%--
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 
--%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>E-Book Store</title>
    </head>
    <body>
        <%
        Basket basket=(Basket)(session.getAttribute("basket"));  
        %>
        <div align="left">
            <table border="0" width="41%" cellspacing="0" cellpadding="0" height="270" bordercolor="#C0C0C0">
                <tr>
                    <td height="58" bgcolor=#0099CC>
                        <p align="center">
                        <b>
                        <font size="4" color="#008000" face="Tahoma">My Basket</font></b><font size="4">
                    </font>						</td>
                </tr>
                <tr>
                    <td bgcolor=#DDDDDD height="27">
                        <p align="center"><font face="Tahoma">
                                <a href=login.jsp>
                            <font color=#333333 size="2">ReadyToBuy</font></a></font><font face="Tahoma" size="2"><u><font color="#808000">
                            </font></u></font>
                        </p>
                        <p align="center">&nbsp;</p>
                    </td>
                </tr>
                <tr>
                    <td height="82">
                        <table width="579">
                            <jsp:useBean id="DataOperation" class="Model.DataOperation" scope="page"/>
                            <%
                            Iterator iterator=basket.getIterator();
                            ArrayList books=basket.getBooks();
                            Connection con=DataOperation.getConnection();
                            Statement st=con.createStatement();
                            while(iterator.hasNext()) {
                                Book b=(Book)iterator.next();
                                String isbn=b.getISBN();
                                ResultSet rs=st.executeQuery("select * from book where isbn='"+isbn+"'");
                            %> 
                            <tr>
                                <td width="285" align="right" height="18">
                                <font face="Tahoma" size="1">Book Title:</font></td>
                                <td width="284" height="18">
                                    <font face="Tahoma" size="1">
                                        <%
                                        rs.next();
                                        out.println(rs.getString("Title"));
                                        %>
                                    </font>
                                </td>
                            </tr>
                            <tr><td width="285" align="right" height="18">
                                    <font face="Tahoma" size="1">Price: &nbsp;
                                    </font>
                                </td>
                                <td width="284" height="18">
                                    <p align="left">
                                    <font face="Tahoma" size="1">$
                                        <%
                                        out.println(rs.getString("price"));
                                        %>
                                        Yuan
                                    </font>
                                </td>
                            </tr>
                            <tr>
                                <td width="285" align="right" height="18">
                                    <font face="Tahoma" size="1">Quantity:
                                    </font>
                                </td>
                                <td width="284" height="18">
                                    <font face="Tahoma" size="1">
                                        <%
                                        out.println(basket.getBook(isbn).getQuanty());
                                        %>
                                    </font>
                                </td>
                            </tr>
                            <tr>
                                <td colspan=2>
                                <hr width="100%">
                            </tr>
                            <%
                            }
                            %>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td>
                        <table width="100%">
                            <tr>
                                <td width="49%">
                                    <p align="right">
                                    <font size="1" face="Tahoma">Total Price </font>
                                </td>
                                <td width="49%">
                                    <p align="left">
                                    <font face="Tahoma" size="1">
                                        <%
                                        out.println(basket.getTotal());
                                        %>
                                    </font>
                                </td>
                            </tr>
                    </table></td>
                </tr>
                <tr>
                    <td bgcolor="#FFFFFF" height="19">
                        <font size="1">
                            <%
                            request.getSession(true).setAttribute("basket",basket);
                            %>
                        </font>
                        <p align="center">					
                            <a href="ClearBasket">
                            <font color="#000000" size="2">ClearBasket</font></a><u><font size="2">
                                </font>
                            </u>
                        </p>
                    </td>
                </tr>
                <tr>
                    <td bgcolor="#DDDDDD" height="45">
                        <p align="center"><font face="Tahoma" size="1">
                            <font color="#808000">&nbsp;&nbsp;</font><font color="#333333"> </font>
                        </font><font face="Tahoma" size="2">
                            <a href=login.jsp>
                        <font color="#333333">ReadyToBuy</font></a></font><font color="#333333"><font face="Tahoma" size="2"><u>
                            </u></font><font face="Tahoma" size="1">
                    &nbsp;</font></font></td>
                </tr>
            </table>
        </div>        
        <p align="center">&nbsp;</p>
    </body>
</html>

⌨️ 快捷键说明

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