?? shopcart_0002ejsp_jsp.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\">¥");
// 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\">¥");
// 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\">¥");
// 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\"> </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\">¥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\">¥");
// 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> </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 + -