⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 search.jsp

📁 在网上书店买书
💻 JSP
字号:
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@ page import="java.sql.*" %>
<%@ page import="Model.DataOperation" %>
<%--
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>
        <jsp:useBean id="DataOperation" class="Model.DataOperation" scope="page"/>
        <table width="604" height="248">
            <%
            String value=request.getParameter("R1");
            String keyWord=request.getParameter("keywords");
            Connection con=DataOperation.getConnection();
            Statement st=con.createStatement();
            String sql=null;
            if(value.equals("Title")) {
                sql="select * from book where"+" "+value+" "+"like"+" "+"'"+"%"+keyWord+"%'";
            } else if(value.equals("Author")) {
                sql="select * from book,author,writes where book.isbn=writes.isbn and writes.authorid=author.authorid and authorname like"+" "+"'%"+keyWord+"%'";
            } else {
                sql="select * from book,publisher where book.publisherid=publisher.publisherid and publishername like"+" "+"'%"+keyWord+"%'";
            }
            ResultSet rs=st.executeQuery(sql);
            while(rs.next()){
            %>
            <tr>
                <td bgcolor="#0099CC" width="305" height="64">
                    <p align="center"><b>
                        <font face="Tahoma" color="#008000">
                book title</font></b></td>
                <td bgcolor="#0099CC" height="64">
                    <font color= #008000>
                        <%
                        String title=rs.getString("Title");
                        out.println(title);
                        %>
                    </font>
                </td>
            </tr>
            <tr>
                <td width="305" height="41">
                    <p align="center" color="#C0C0C0">Price</p>
                </td>
                <td height="41">
                    <%
                    double price=rs.getDouble("price");
                    out.println(price);
                    %>
                </td>
            </tr>
            <tr>
                <td width="305" height="43">
                    <p align="center" color="#C0C0C0">Date of 
                    Publication
                </td>
                <td height="43">
                    <%
                    Date date=rs.getDate("PublicationDate");
                    out.println(date);
                    %>
                </td>
            </tr>
            <tr>
                <td width="305">
                    <p align="center">
                        <form action="ShowDetals.jsp" method=post>
                            <p align="center">
                                <input type="hidden" value=<%out.println(rs.getString("ISBN"));%>  name="ISBN">
                                <input type="submit" value="detals">
                            </p>
                        </form>
                    </p>
                </td>
                
                <td><p align="center">
                        <form method="post" action="BuyController">
                            
                            <p align="center">
                                
                                <input type="submit" value="Buy">
                                <input type="hidden" name="ISBN" value=<%out.println(rs.getString("ISBN"));%>>
                                    <input type="hidden" name="Title"value=<%out.println(rs.getString("Title"));%> >
                                    <input type="hidden" name="Price"value=<%out.println(rs.getDouble("price"));%> >
                                    
                                </p>
                            
                    </form></p>
                </td>
            </tr>
            <%
            }
            %>
            <hr/>
        </table>
    </body>
</html>

⌨️ 快捷键说明

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