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

📄 buy_0002ejsp_jsp.java

📁 很实用的JSP代码
💻 JAVA
字号:
import bookshop.book.book;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import org.apache.jasper.runtime.*;


public class buy_0002ejsp_jsp extends HttpJspBase {

    // begin [file="/buy.jsp";from=(4,0);to=(4,67)]
    // end
    // begin [file="/buy.jsp";from=(5,0);to=(5,66)]
    // end

    static {
    }
    public buy_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=GB2312");
            pageContext = _jspxFactory.getPageContext(this, request, response,
            			"", true, 8192, true);

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

            // HTML // begin [file="/buy.jsp";from=(0,88);to=(2,0)]
                out.write("\r\n\r\n");

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

            // end
            // HTML // begin [file="/buy.jsp";from=(3,39);to=(4,0)]
                out.write("\r\n");

            // end
            // begin [file="/buy.jsp";from=(4,0);to=(4,67)]
                bookshop.run.op_book book = null;
                boolean _jspx_specialbook  = false;
                 synchronized (pageContext) {
                    book= (bookshop.run.op_book)
                    pageContext.getAttribute("book",PageContext.PAGE_SCOPE);
                    if ( book == null ) {
                        _jspx_specialbook = true;
                        try {
                            book = (bookshop.run.op_book) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "bookshop.run.op_book");
                        } catch (ClassNotFoundException exc) {
                             throw new InstantiationException(exc.getMessage());
                        } catch (Exception exc) {
                             throw new ServletException (" Cannot create bean of class "+"bookshop.run.op_book", exc);
                        }
                        pageContext.setAttribute("book", book, PageContext.PAGE_SCOPE);
                    }
                 } 
                if(_jspx_specialbook == true) {
            // end
            // begin [file="/buy.jsp";from=(4,0);to=(4,67)]
                }
            // end
            // HTML // begin [file="/buy.jsp";from=(4,67);to=(5,0)]
                out.write("\r\n");

            // end
            // begin [file="/buy.jsp";from=(5,0);to=(5,66)]
                bookshop.run.op_buy shop = null;
                boolean _jspx_specialshop  = false;
                 synchronized (pageContext) {
                    shop= (bookshop.run.op_buy)
                    pageContext.getAttribute("shop",PageContext.PAGE_SCOPE);
                    if ( shop == null ) {
                        _jspx_specialshop = true;
                        try {
                            shop = (bookshop.run.op_buy) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "bookshop.run.op_buy");
                        } catch (ClassNotFoundException exc) {
                             throw new InstantiationException(exc.getMessage());
                        } catch (Exception exc) {
                             throw new ServletException (" Cannot create bean of class "+"bookshop.run.op_buy", exc);
                        }
                        pageContext.setAttribute("shop", shop, PageContext.PAGE_SCOPE);
                    }
                 } 
                if(_jspx_specialshop == true) {
            // end
            // begin [file="/buy.jsp";from=(5,0);to=(5,66)]
                }
            // end
            // HTML // begin [file="/buy.jsp";from=(5,66);to=(7,0)]
                out.write("\r\n\r\n");

            // end
            // begin [file="/buy.jsp";from=(7,2);to=(33,0)]
                
                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 = "你要购买的图书不存在!";
                		}
                	}
                }
            // end
            // HTML // begin [file="/buy.jsp";from=(33,2);to=(61,3)]
                out.write("\r\n<html>\r\n<head>\r\n<title>隽隽书店在线 购买图书</title>\r\n\r\n<script language=\"javascript\">\r\n\r\nfunction openScript(url,name, width, height){\r\n\tvar Win = window.open(url,name,'width=' + width + ',height=' + height + ',resizable=1,scrollbars=yes,menubar=no,status=yes' );\r\n}\r\n\r\nfunction check()\r\n{\r\n\tif (document.form1.amount.value<1){\r\n\t\talert(\"你的购买数量有问题\");\r\n\t\tdocument.form1.amount.focus();\r\n\t\treturn false;\r\n\t}\r\n\treturn true;\r\n}\r\n\r\n</script>\r\n<link rel=\"stylesheet\" href=\"books.css\" type=\"text/css\">\r\n</head>\r\n\r\n<body bgcolor=\"#FFCC99\" text=\"#000000\" onload=\"javascript:window.focus();\">\r\n<div align=\"center\">\r\n  <p>隽隽书店欢迎你<font color=\"#CC0066\">选购图书</font>!</p>\r\n   ");

            // end
            // begin [file="/buy.jsp";from=(61,5);to=(65,1)]
                 if(!mesg.equals("")){
                		out.println(mesg);
                	  } else {
                		book bk = (book) book.getBooklist().elementAt(0);
                	
            // end
            // HTML // begin [file="/buy.jsp";from=(65,3);to=(69,31)]
                out.write("\r\n  <table width=\"90%\" border=\"0\" cellspacing=\"2\" cellpadding=\"1\">\r\n    <form name=\"form1\" method=\"post\" action=\"buy.jsp\">\r\n      <tr>\r\n        <td align=\"center\">图书名:");

            // end
            // begin [file="/buy.jsp";from=(69,34);to=(69,52)]
                out.print( bk.getBookName() );
            // end
            // HTML // begin [file="/buy.jsp";from=(69,54);to=(77,46)]
                out.write("</td>\r\n      </tr>\r\n      <tr align=\"center\">\r\n        <td>你想要的数量:\r\n          <input type=\"text\" name=\"amount\" maxlength=\"4\" size=\"3\" value=\"1\"> 本</td>\r\n      </tr>\r\n      <tr align=\"center\">\r\n        <td>\r\n\t\t  <input type=\"hidden\" name=\"bookid\" value=\"");

            // end
            // begin [file="/buy.jsp";from=(77,49);to=(77,52)]
                out.print(Id );
            // end
            // HTML // begin [file="/buy.jsp";from=(77,54);to=(83,63)]
                out.write("\">\r\n          <input type=\"submit\" name=\"Submit\" value=\"购 买\" onclick=\"return(check());\">\r\n          <input type=\"reset\" name=\"Reset\" value=\"取 消\">\r\n        </td>\r\n      </tr>\r\n\t   <tr align=\"center\">\r\n        <td><a href=\"#\" onclick=\"openScript('detail.jsp?bookid=");

            // end
            // begin [file="/buy.jsp";from=(83,66);to=(83,70)]
                out.print( Id );
            // end
            // HTML // begin [file="/buy.jsp";from=(83,72);to=(87,0)]
                out.write("','show',400,450)\" >查看详细资料</a> </td>\r\n      </tr>\r\n    </form>\r\n  </table>\r\n");

            // end
            // begin [file="/buy.jsp";from=(87,2);to=(87,5)]
                 } 
            // end
            // HTML // begin [file="/buy.jsp";from=(87,7);to=(101,0)]
                out.write("\r\n  <br>\r\n  <p><a href=\"javascript:window.close()\">关闭窗口</a></p>\r\n  <table width=\"100%\" border=\"0\" cellspacing=\"2\" cellpadding=\"2\">\r\n    <tr>\r\n      <td align=\"center\">隽隽书店在线<br>\r\n        CopyRight@2004 <br>\r\n        Email:<a href=\"mailto:wxy8108123@163.com\">wxy8108123@163.com</a></td>\r\n    </tr>\r\n  </table>\r\n\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 + -