?? books_jsp.java
字號:
String sPage = "";
out.println(" <table style=\"\">");
out.println(" <form method=\"get\" action=\"Books.jsp\" name=\"Search\">\n <tr>");
// Set variables with search parameters
fldcategory_id = getParam( request, "category_id");
fldname = getParam( request, "name");
// Show fields
out.println(" <td style=\"background-color: #FFEAC5; border-style: inset; border-width: 0\"><font style=\"font-size: 10pt; color: #000000\">分類</font></td>");
out.print(" <td style=\"background-color: #FFFFFF; border-width: 1\">");
out.print("<select name=\"category_id\">"+getOptions( conn, "select category_id, name from categories order by 2",true,false,fldcategory_id)+"</select>");
out.println("</td>\n </tr>\n <tr>");
out.println(" <td style=\"background-color: #FFEAC5; border-style: inset; border-width: 0\"><font style=\"font-size: 10pt; color: #000000\">相關詞</font></td>");
out.print(" <td style=\"background-color: #FFFFFF; border-width: 1\">"); out.print("<input type=\"text\" name=\"name\" maxlength=\"10\" value=\""+toHTML(fldname)+"\" size=\"10\">");
out.println("</td>\n </tr>\n <tr>");
out.println(" <td align=\"right\" colspan=\"3\"><input type=\"submit\" value=\"開始\"/></td>");
out.println(" </tr>\n </form>\n </table>");
out.println("");
}
catch (Exception e) { out.println(e.toString()); }
}
void AdvMenu_Show (javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.http.HttpSession session, javax.servlet.jsp.JspWriter out, String sAdvMenuErr, String sForm, String sAction, java.sql.Connection conn, java.sql.Statement stat) throws java.io.IOException {
try {
out.println(" <table style=\"\">");
out.print(" <tr>");
// Set URLs
String fldField1 = "AdvSearch.jsp";
// Show fields
out.print("\n <td style=\"background-color: #FFFFFF; border-width: 1\"><a href=\""+fldField1+"\"><font style=\"font-size: 10pt; color: #000000\">高級搜索</font></a></td>");
out.println("\n </tr>\n </table>");
}
catch (Exception e) { out.println(e.toString()); }
}
void Total_Show (javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.http.HttpSession session, javax.servlet.jsp.JspWriter out, String sTotalErr, String sForm, String sAction, java.sql.Connection conn, java.sql.Statement stat) throws java.io.IOException {
String sWhere = "";
int iCounter=0;
int iPage = 0;
boolean bIsScroll = true;
boolean hasParam = false;
String sOrder = "";
String sSQL="";
String transitParams = "";
String sQueryString = "";
String sPage = "";
int RecordsPerPage = 20;
String sSortParams = "";
String formParams = "";
String pauthor="";
String pcategory_id="";
String pname="";
String ppricemax="";
String ppricemin="";
formParams = "category_id=" + toURL(getParam( request, "category_id")) + "&name=" + toURL(getParam( request, "name")) + "&author=" + toURL(getParam( request, "author")) + "&pricemin=" + toURL(getParam( request, "pricemin")) + "&pricemax=" + toURL(getParam( request, "pricemax")) + "&";
// Build WHERE statement
//-- Check author parameter and create a valid sql for where clause
pauthor = getParam( request, "author");
if (pauthor != null && ! pauthor.equals("")) {
hasParam = true;
sWhere += "i.author like '%" + replace(pauthor, "'", "''") + "%'";
}
//-- Check category_id parameter and create a valid sql for where clause
pcategory_id = getParam( request, "category_id");
if ( ! isNumber (pcategory_id)) {
pcategory_id = "";
}
if (pcategory_id != null && ! pcategory_id.equals("")) {
if (! sWhere.equals("")) sWhere += " and ";
hasParam = true;
sWhere += "i.category_id=" + pcategory_id;
}
//-- Check name parameter and create a valid sql for where clause
pname = getParam( request, "name");
if (pname != null && ! pname.equals("")) {
if (! sWhere.equals("")) sWhere += " and ";
hasParam = true;
sWhere += "i.name like '%" + replace(pname, "'", "''") + "%'";
}
//-- Check pricemax parameter and create a valid sql for where clause
ppricemax = getParam( request, "pricemax");
if ( ! isNumber (ppricemax)) {
ppricemax = "";
}
if (ppricemax != null && ! ppricemax.equals("")) {
if (! sWhere.equals("")) sWhere += " and ";
hasParam = true;
sWhere += "i.price<=" + ppricemax;
}
//-- Check pricemin parameter and create a valid sql for where clause
ppricemin = getParam( request, "pricemin");
if ( ! isNumber (ppricemin)) {
ppricemin = "";
}
if (ppricemin != null && ! ppricemin.equals("")) {
if (! sWhere.equals("")) sWhere += " and ";
hasParam = true;
sWhere += "i.price>=" + ppricemin;
}
if (hasParam) { sWhere = " WHERE (" + sWhere + ")"; }
// Build full SQL statement
sSQL = "select i.author as i_author, " +
"i.category_id as i_category_id, " +
"i.item_id as i_item_id, " +
"i.name as i_name, " +
"i.price as i_price " +
" from items i ";
sSQL="select count(item_id) as i_item_id from items as i";
sSQL = sSQL + sWhere + sOrder;
String sNoRecords = " <tr>\n <td colspan=\"2\" style=\"background-color: #FFFFFF; border-width: 1\"><font style=\"font-size: 10pt; color: #000000\">沒有條目</font></td>\n </tr>";
String tableHeader = "";
try {
out.println(" <table style=\"\">");
out.println(tableHeader);
}
catch (Exception e) {}
try {
java.sql.ResultSet rs = null;
// Open recordset
rs = openrs( stat, sSQL);
iCounter = 0;
java.util.Hashtable rsHash = new java.util.Hashtable();
String[] aFields = getFieldsName( rs );
// Show main table based on recordset
while ( rs.next() ) {
getRecordToHash( rs, rsHash, aFields );
String flditem_id = (String) rsHash.get("i_item_id");
out.print(" <tr>\n <td style=\"background-color: #FFFFFF; border-style: inset; border-width: 0\"><font style=\"font-size: 10pt; color: #CE7E00; font-weight: bold\">找到的條目:</font> </td><td style=\"background-color: #FFFFFF; border-width: 1\">"); out.print("<font style=\"font-size: 10pt; color: #000000\">"+toHTML(flditem_id)+" </font>");
out.println("</td>\n </tr>");
out.println(" <tr>\n <td colspan=\"2\" style=\"background-color: #FFFFFF; border-width: 1\"> </td>\n </tr>");
iCounter++;
}
if (iCounter == 0) {
// Recordset is empty
out.println(sNoRecords);
iCounter = RecordsPerPage+1;
bIsScroll = false;
}
if ( rs != null ) rs.close();
out.println(" </table>");
}
catch (Exception e) { out.println(e.toString()); }
}
private static java.util.Vector _jspx_dependants;
static {
_jspx_dependants = new java.util.Vector(1);
_jspx_dependants.add("/pages/Common.jsp");
}
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');
out.write('\n');
boolean bDebug = false;
String sAction = getParam( request, "FormAction");
String sForm = getParam( request, "FormName");
String sResultsErr = "";
String sSearchErr = "";
String sAdvMenuErr = "";
String sTotalErr = "";
java.sql.Connection conn = null;
java.sql.Statement stat = null;
String sErr = loadDriver();
conn = cn();
stat = conn.createStatement();
if ( ! sErr.equals("") ) {
try {
out.println(sErr);
}
catch (Exception e) {}
}
out.write(" \r\n");
out.write("<html>\r\n");
out.write("<head>\r\n");
out.write("<title>Book Store</title>\r\n");
out.write("<meta name=\"GENERATOR\" content=\"YesSoftware CodeCharge v.1.2.0 / JSP.ccp build 05/21/2001\"/>\r\n");
out.write("<meta http-equiv=\"pragma\" content=\"no-cache\"/>\r\n");
out.write("<meta http-equiv=\"expires\" content=\"0\"/>\r\n");
out.write("<meta http-equiv=\"cache-control\" content=\"no-cache\"/>\r\n");
out.write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\">\r\n");
out.write("</head>\r\n");
out.write("<body style=\"background-color: #FFFFFF; color: #000000; font-family: Arial, Tahoma, Verdana, Helveticabackground-color: #FFFFFF; color: #000000; font-family: Arial, Tahoma, Verdana, Helvetica\">\r\n");
org.apache.jasper.runtime.JspRuntimeLibrary.include(request, response, "Header.jsp", out, true);
out.write("\r\n");
out.write(" <table>\r\n");
out.write(" <tr>\r\n");
out.write(" \r\n");
out.write(" <td valign=\"top\">\r\n");
Search_Show(request, response, session, out, sSearchErr, sForm, sAction, conn, stat);
out.write("\r\n");
out.write(" \r\n");
out.write(" </td>\r\n");
out.write(" <td valign=\"top\">\r\n");
AdvMenu_Show(request, response, session, out, sAdvMenuErr, sForm, sAction, conn, stat);
out.write("\r\n");
out.write(" \r\n");
out.write(" </td>\r\n");
out.write(" </tr>\r\n");
out.write(" </table>\r\n");
out.write(" <table>\r\n");
out.write(" <tr>\r\n");
out.write(" <td valign=\"top\">\r\n");
Total_Show(request, response, session, out, sTotalErr, sForm, sAction, conn, stat);
out.write("\r\n");
out.write(" \r\n");
out.write(" </td>\r\n");
out.write(" </tr>\r\n");
out.write(" </table>\r\n");
out.write(" <table>\r\n");
out.write(" <tr>\r\n");
out.write(" <td valign=\"top\">\r\n");
Results_Show(request, response, session, out, sResultsErr, sForm, sAction, conn, stat);
out.write("\r\n");
out.write(" \r\n");
out.write(" </td>\r\n");
out.write(" </tr>\r\n");
out.write(" </table>\r\n");
org.apache.jasper.runtime.JspRuntimeLibrary.include(request, response, "Footer.jsp", out, true);
out.write("\r\n");
out.write("</body>\r\n");
out.write("</html>\r\n");
out.write('\r');
out.write('\n');
if ( stat != null ) stat.close();
if ( conn != null ) conn.close();
out.write('\r');
out.write('\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 + -