📄 purchase_jsp.java
字号:
package org.apache.jsp;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import com.mybusiness.web.ware.ware;
public final class purchase_jsp extends org.apache.jasper.runtime.HttpJspBase
implements org.apache.jasper.runtime.JspSourceDependent {
private static java.util.Vector _jspx_dependants;
public java.util.List getDependants() {
return _jspx_dependants;
}
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;
JspWriter _jspx_out = null;
PageContext _jspx_page_context = null;
try {
_jspxFactory = JspFactory.getDefaultFactory();
response.setContentType("text/html; charset=gb2312");
pageContext = _jspxFactory.getPageContext(this, request, response,
null, true, 8192, true);
_jspx_page_context = pageContext;
application = pageContext.getServletContext();
config = pageContext.getServletConfig();
session = pageContext.getSession();
out = pageContext.getOut();
_jspx_out = out;
out.write("\r\n");
out.write("\r\n");
out.write("\r\n");
com.mybusiness.web.waremn book = null;
synchronized (_jspx_page_context) {
book = (com.mybusiness.web.waremn) _jspx_page_context.getAttribute("book", PageContext.PAGE_SCOPE);
if (book == null){
book = new com.mybusiness.web.waremn();
_jspx_page_context.setAttribute("book", book, PageContext.PAGE_SCOPE);
}
}
out.write('\r');
out.write('\n');
com.mybusiness.web.purchase shop = null;
synchronized (_jspx_page_context) {
shop = (com.mybusiness.web.purchase) _jspx_page_context.getAttribute("shop", PageContext.PAGE_SCOPE);
if (shop == null){
shop = new com.mybusiness.web.purchase();
_jspx_page_context.setAttribute("shop", shop, PageContext.PAGE_SCOPE);
}
}
out.write("\r\n");
out.write("\r\n");
String mesg = "";
String submits = request.getParameter("Submit");
int Id=0;
if (submits!=null && !submits.equals("")){
if (shop.addnew(request)){
mesg = "你要的商品已经放入你的购物车中!谢谢";
} else if (shop.getIsEmpty()){
mesg = "库存商品数量不足!只剩"+shop.getLeaveBook()+"本";
} else {
mesg = "暂时不能购买!";
}
}else {
if (request.getParameter("bookid")==null || request.getParameter("bookid").equals("")) {
mesg = "你要购买的商品不存在!";
} else {
try {
Id = Integer.parseInt(request.getParameter("bookid"));
if (!book.getOnebook(Id)){
mesg = "你要购买的商品不存在!";
}
} catch (Exception e){
mesg = "你要购买的商品不存在!";
}
}
}
out.write("\r\n");
out.write("<html>\r\n");
out.write("<head>\r\n");
out.write("<title>商场翱游购物系统 购买商品</title>\r\n");
out.write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=gb2312\">\r\n");
out.write("<script language=\"javascript\">\r\n");
out.write("\r\n");
out.write("function openScript(url,name, width, height){\r\n");
out.write("\tvar Win = window.open(url,name,'width=' + width + ',height=' + height + ',resizable=1,scrollbars=yes,menubar=no,status=yes' );\r\n");
out.write("}\r\n");
out.write("\r\n");
out.write("function check()\r\n");
out.write("{\r\n");
out.write("\tif (document.form1.amount.value<1){\r\n");
out.write("\t\talert(\"你的购买数量有问题\");\r\n");
out.write("\t\tdocument.form1.amount.focus();\r\n");
out.write("\t\treturn false;\r\n");
out.write("\t}\r\n");
out.write("\treturn true;\r\n");
out.write("}\r\n");
out.write("\r\n");
out.write("</script>\r\n");
out.write("<link rel=\"stylesheet\" href=\"ware.css\" type=\"text/css\">\r\n");
out.write("</head>\r\n");
out.write("\r\n");
out.write("<body background=images/112.gif text=\"#000000\" onload=\"javascript:window.focus();\">\r\n");
out.write("<div align=\"center\">\r\n");
out.write(" <p>商场翱游购物系统欢迎你<font color=\"#CC0066\">选购商品</font>!</p>\r\n");
out.write(" ");
if(!mesg.equals("")){
out.println(mesg);
} else {
ware bk = (ware) book.getBooklist().elementAt(0);
out.write("\r\n");
out.write(" <table width=\"90%\" border=\"0\" cellspacing=\"2\" cellpadding=\"1\">\r\n");
out.write(" <form name=\"form1\" method=\"post\" action=\"purchase.jsp\">\r\n");
out.write(" <tr> \r\n");
out.write(" <td align=\"center\">商品名:");
out.print( bk.getBookName() );
out.write("</td>\r\n");
out.write(" </tr>\r\n");
out.write(" <tr align=\"center\"> \r\n");
out.write(" <td>你想要的数量: \r\n");
out.write(" <input type=\"text\" name=\"amount\" maxlength=\"4\" size=\"3\" value=\"1\"> </td>\r\n");
out.write(" </tr>\r\n");
out.write(" <tr align=\"center\"> \r\n");
out.write(" <td>\r\n");
out.write("\t\t <input type=\"hidden\" name=\"bookid\" value=\"");
out.print(Id );
out.write("\">\r\n");
out.write(" <input type=\"submit\" name=\"Submit\" value=\"购 买\" onclick=\"return(check());\">\r\n");
out.write(" <input type=\"reset\" name=\"Reset\" value=\"取 消\">\r\n");
out.write(" </td>\r\n");
out.write(" </tr>\r\n");
out.write("\t <tr align=\"center\"> \r\n");
out.write(" <td><a href=\"#\" onclick=\"openScript('showware.jsp?bookid=");
out.print( Id );
out.write("','show',400,450)\" >查看详细资料</a> </td>\r\n");
out.write(" </tr>\r\n");
out.write(" </form>\r\n");
out.write(" </table>\r\n");
}
out.write("\r\n");
out.write(" <br>\r\n");
out.write(" <p><a href=\"javascript:window.close()\">关闭窗口</a></p>\r\n");
out.write(" <table width=\"100%\" border=\"0\" cellspacing=\"2\" cellpadding=\"2\">\r\n");
out.write(" <tr>\r\n");
out.write(" <td align=\"center\">开发:王文耀<br>\r\n");
out.write(" CopyRight@2006<br>\r\n");
out.write(" Email:<a href=\"mailto:wwy170@163.com\">wwy170@163.com</a></td>\r\n");
out.write(" </tr>\r\n");
out.write(" </table>\r\n");
out.write(" \r\n");
out.write("</div>\r\n");
out.write("</body>\r\n");
out.write("</html>\r\n");
} catch (Throwable t) {
if (!(t instanceof SkipPageException)){
out = _jspx_out;
if (out != null && out.getBufferSize() != 0)
out.clearBuffer();
if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
}
} finally {
if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -