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

📄 shopcart_0002ejsp_jsp.java

📁 用JAVA编写的网上书店程序
💻 JAVA
字号:
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import org.apache.jasper.runtime.*;


public class shopcart_0002ejsp_jsp extends HttpJspBase {

    // begin [file="/shopcart.jsp";from=(11,0);to=(11,52)]
    // end

    static {
    }
    public shopcart_0002ejsp_jsp( ) {
    }

    private static boolean _jspx_inited = false;

    public final void _jspx_init() throws org.apache.jasper.runtime.JspException {
    }

    public void _jspService(HttpServletRequest request, HttpServletResponse  response)
        throws java.io.IOException, ServletException {

        JspFactory _jspxFactory = null;
        PageContext pageContext = null;
        HttpSession session = null;
        ServletContext application = null;
        ServletConfig config = null;
        JspWriter out = null;
        Object page = this;
        String  _value = null;
        try {

            if (_jspx_inited == false) {
                synchronized (this) {
                    if (_jspx_inited == false) {
                        _jspx_init();
                        _jspx_inited = true;
                    }
                }
            }
            _jspxFactory = JspFactory.getDefaultFactory();
            response.setContentType("text/html; charset=GB18030");
            pageContext = _jspxFactory.getPageContext(this, request, response,
            			"", true, 8192, true);

            application = pageContext.getServletContext();
            config = pageContext.getServletConfig();
            session = pageContext.getSession();
            out = pageContext.getOut();

            // HTML // begin [file="/shopcart.jsp";from=(0,52);to=(1,0)]
                out.write("\r\n");

            // end
            // HTML // begin [file="/shopcart.jsp";from=(1,31);to=(2,0)]
                out.write("\r\n");

            // end
            // begin [file="/shopcart.jsp";from=(2,2);to=(10,0)]
                
                /*检查客户是否通过登录,如果未经过登录检查,返回登录界面。
                *验证用户是否存在,避免用户直接进入该页,以后的每张动态网
                *页都要包括这一部分。*/
                if(session.getAttribute("username")==null)
                {
                  response.sendRedirect("login.html");
                }
            // end
            // HTML // begin [file="/shopcart.jsp";from=(10,2);to=(11,0)]
                out.write("\r\n");

            // end
            // begin [file="/shopcart.jsp";from=(11,0);to=(11,52)]
                book.bk bkId = null;
                boolean _jspx_specialbkId  = false;
                 synchronized (pageContext) {
                    bkId= (book.bk)
                    pageContext.getAttribute("bkId",PageContext.PAGE_SCOPE);
                    if ( bkId == null ) {
                        _jspx_specialbkId = true;
                        try {
                            bkId = (book.bk) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "book.bk");
                        } catch (ClassNotFoundException exc) {
                             throw new InstantiationException(exc.getMessage());
                        } catch (Exception exc) {
                             throw new ServletException (" Cannot create bean of class "+"book.bk", exc);
                        }
                        pageContext.setAttribute("bkId", bkId, PageContext.PAGE_SCOPE);
                    }
                 } 
                if(_jspx_specialbkId == true) {
            // end
            // begin [file="/shopcart.jsp";from=(11,0);to=(11,52)]
                }
            // end
            // HTML // begin [file="/shopcart.jsp";from=(11,52);to=(42,8)]
                out.write("\r\n<html>\r\n<head>\r\n<title>[详细资料]</title>\r\n</head>\r\n<body bgcolor=\"#ffffff\">\r\n  <div align=\"center\">\r\n    <table width=\"100%\"border=\"0\"bgcolor=\"#ccccff\">\r\n      <tr>\r\n        <td>\r\n          <div align=\"center\"> <b><font color=\"#ff0000\">购书清单</font></b></div>\r\n        </td>\r\n      </tr>\r\n    </table>\r\n    <form name=\"form1\" method=\"POST\" action=\"order.jsp\">\r\n      <p>您已经选购以下书籍</p>\r\n      <table width=\"100%\"border=\"0\"align=\"center\">\r\n        <tr bgcolor=\"#ffcccc\">\r\n          <td width=\"15%\">\r\n            <div align=\"center\"><font color=\"#0000ff\">购买数量</font></div>\r\n          </td>\r\n          <td width=\"56%\">\r\n            <div align=\"center\"><font  color=\"#0000ff\">书名</font> </div>\r\n          </td>\r\n          <td width=\"13%\">\r\n            <div align=\"center\"><font  color=\"#0000ff\">单价(元)</font> </div>\r\n          </td>\r\n          <td width=\"16%\">\r\n            <div align=\"center\"><font  color=\"#0000ff\">总价格(元)</font> </div>\r\n          </td>\r\n        </tr>\r\n        ");

            // end
            // begin [file="/shopcart.jsp";from=(42,10);to=(56,9)]
                
                        //价格
                        double g_price,total_price;
                        g_price=0;
                        total_price=0;
                        //********
                        String sqlList="select * from 订单表 where user_name='"+session.getAttribute("username")+"'";
                        ResultSet RSList=bkId.executeQuery(sqlList);
                        try
                        {
                          while(RSList.next())
                          {
                            int b_num;
                            b_num=RSList.getInt("book_number");
                         
            // end
            // HTML // begin [file="/shopcart.jsp";from=(56,11);to=(59,55)]
                out.write("\r\n         <tr bgcolor=\"#ccffcc\">\r\n           <td width=\"15%\">\r\n             <div align=\"center\"><font color=\"#0000ff\">");

            // end
            // begin [file="/shopcart.jsp";from=(59,58);to=(59,63)]
                out.print(b_num);
            // end
            // HTML // begin [file="/shopcart.jsp";from=(59,65);to=(60,67)]
                out.write("\r\n               <input type=\"hidden\"name=\"book_number\"size=\"4\"value=");

            // end
            // begin [file="/shopcart.jsp";from=(60,70);to=(60,75)]
                out.print(b_num);
            // end
            // HTML // begin [file="/shopcart.jsp";from=(60,77);to=(64,11)]
                out.write(">\r\n\t\t</font>\r\n              </div>\r\n           </td>\r\n           ");

            // end
            // begin [file="/shopcart.jsp";from=(64,13);to=(69,11)]
                
                           String sqlBook="select * from 书籍信息表 where id="+RSList.getInt("book_id");
                           ResultSet RSBook=bkId.executeQuery(sqlBook);
                           while(RSBook.next())
                           {
                           
            // end
            // HTML // begin [file="/shopcart.jsp";from=(69,13);to=(71,55)]
                out.write("\r\n           <td width=\"56%\">\r\n             <div align=\"center\"><font color=\"#0000ff\">");

            // end
            // begin [file="/shopcart.jsp";from=(71,58);to=(71,82)]
                out.print(RSBook.getString("name"));
            // end
            // HTML // begin [file="/shopcart.jsp";from=(71,84);to=(75,13)]
                out.write("\r\n             </font></div>\r\n           </td>\r\n           <td width=\"13%\">\r\n             ");

            // end
            // begin [file="/shopcart.jsp";from=(75,15);to=(78,13)]
                
                             double price;
                             price=RSBook.getDouble("price");
                             
            // end
            // HTML // begin [file="/shopcart.jsp";from=(78,15);to=(79,60)]
                out.write("\r\n             <div align=\"center\"><font color=\"#0000ff\">&yen;");

            // end
            // begin [file="/shopcart.jsp";from=(79,63);to=(79,68)]
                out.print(price);
            // end
            // HTML // begin [file="/shopcart.jsp";from=(79,70);to=(82,59)]
                out.write("</font></div>\r\n          </td>\r\n          <td width=\"16%\">\r\n            <div align=\"center\"><font color=\"#0000ff\">&yen;");

            // end
            // begin [file="/shopcart.jsp";from=(82,62);to=(82,80)]
                out.print((float)price*b_num);
            // end
            // HTML // begin [file="/shopcart.jsp";from=(82,82);to=(84,10)]
                out.write("</font></div>\r\n          </td>\r\n          ");

            // end
            // begin [file="/shopcart.jsp";from=(84,12);to=(86,12)]
                
                          g_price=g_price+(double)price*b_num;
                           }
            // end
            // HTML // begin [file="/shopcart.jsp";from=(86,14);to=(88,9)]
                out.write("\r\n         </tr>\r\n         ");

            // end
            // begin [file="/shopcart.jsp";from=(88,11);to=(94,8)]
                
                          }
                        }
                        catch(Exception e)
                        {
                        }
                        
            // end
            // HTML // begin [file="/shopcart.jsp";from=(94,10);to=(101,59)]
                out.write("\r\n\r\n        <tr bgcolor=\"#ccccff\">\r\n          <td colspan=\"3\">\r\n            <div align=\"center\"><font color=\"#0000ff\">货物价格</font></div>\r\n          </td>\r\n          <td width=\"16%\">\r\n            <div align=\"center\"><font color=\"#0000ff\">&yen;");

            // end
            // begin [file="/shopcart.jsp";from=(101,62);to=(101,76)]
                out.print((float)g_price);
            // end
            // HTML // begin [file="/shopcart.jsp";from=(101,78);to=(118,62)]
                out.write("</font></div>\r\n          </td>\r\n        </tr>\r\n        <tr>\r\n          <td height=\"18\"colspan=\"3\"bgcolor=\"#cccc99\"><font color=\"#0000ff\">&nbsp;</font>\r\n            <div align=\"center\"><font color=\"#0000ff\">运输费用</font></div>\r\n          </td>\r\n          <td height=\"18\" width=\"16%\" bgcolor=\"#cccc99\">\r\n            <div align=\"center\"><font color=\"#0000ff\">&yen;5.00</font></div>\r\n          </td>\r\n        </tr>\r\n\r\n        <tr bgcolor=\"#66ff66\">\r\n          <td colspan=\"3\">\r\n            <div align=\"center\"><b><font color=\"#ff0000\">总费用</font></b></div>\r\n          </td>\r\n          <td width=\"16%\">\r\n            <div align=\"center\"><b><font color=\"#ff0000\">&yen;");

            // end
            // begin [file="/shopcart.jsp";from=(118,65);to=(118,81)]
                out.print((float)g_price+5);
            // end
            // HTML // begin [file="/shopcart.jsp";from=(118,83);to=(134,0)]
                out.write("</font></b></div>\r\n          </td>\r\n        </tr>\r\n        <tr align=\"center\">\r\n          <td colspan=\"4\">\r\n            <a href=\"browse.jsp\">继续购书</a>\r\n            <!--<input type=\"submit\"name=\"Submit\"value=\"重新计算价格\">-->\r\n              <input type=\"submit\"name=\"Submit2\"value=\"填写订单\">\r\n          </td>\r\n        </tr>\r\n      </table>\r\n    </form>\r\n    <p>&nbsp;</p>\r\n  </div>\r\n</body>\r\n</html>\r\n");

            // end

        } catch (Throwable t) {
            if (out != null && out.getBufferSize() != 0)
                out.clearBuffer();
            if (pageContext != null) pageContext.handlePageException(t);
        } finally {
            if (_jspxFactory != null) _jspxFactory.releasePageContext(pageContext);
        }
    }
}

⌨️ 快捷键说明

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