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

📄 viewcategory_jsp.java

📁 一个jsp连接数据库的实例
💻 JAVA
字号:
package org.apache.jsp;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import java.sql.*;
import product_web.*;
import java.util.*;
import java.io.*;
import java.io.*;

public final class viewCategory_jsp extends org.apache.jasper.runtime.HttpJspBase
    implements org.apache.jasper.runtime.JspSourceDependent {

 String trans(String chi)
{
               String result = "";
               byte temp [];
               try
               {
                       temp=chi.getBytes("iso-8859-1");
                      result = new String(temp);
                }
                catch(UnsupportedEncodingException e)
                {
                        System.out.println (e.toString());
                }
			return result;
}

 String catid,name,descn,sql;
  private static java.util.Vector _jspx_dependants;

  static {
    _jspx_dependants = new java.util.Vector(1);
    _jspx_dependants.add("/trans.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,
      			"error.jsp", 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');
      out.write("<style type=\"text/css\">\r\n<!--\r\nbody {\r\n\tbackground-image: url(background.jpg);\r\n}\r\n-->\r\n</style>\r\n");
      out.write("\r\n<html>\r\n<head>\r\n<title>Untitled Document</title>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=gb2312\">\r\n<style type=\"text/css\">\r\n<!--\r\nbody {\r\n\tbackground-image: url(background.jpg);\r\n}\r\n-->\r\n</style></head>\r\n");
      product_web.ViewCategory category = null;
      synchronized (_jspx_page_context) {
        category = (product_web.ViewCategory) _jspx_page_context.getAttribute("category", PageContext.PAGE_SCOPE);
        if (category == null){
          category = new product_web.ViewCategory();
          _jspx_page_context.setAttribute("category", category, PageContext.PAGE_SCOPE);
        }
      }
      out.write("\r\n<body>\r\n<center>\r\n<h1>查看所有的书籍类别</h1>\r\n<table width=80% border=\"1\" bgcolor=\"#0099CC\"><tr bgcolor=\"#009966\" bordercolor=\"#990066\"><td>id</td><td>类别名</td><td>描述</td></tr>\r\n");
      out.write('\r');
      out.write('\n');

	sql = "select * from category";
	ResultSet rs = category.executeQuery(sql);
while(rs.next())
{
    catid = rs.getString("catid");
    name = rs.getString("name");
    descn = rs.getString("descn");
  
      out.write("\r\n    <tr bordercolor=#990066>\r\n\t");
 out.println("<td><a href='searchProductByCategory.jsp?category="+catid+"'>"+catid+"</a></td>"); 
      out.write("\r\n\t<td>");
      out.print( name );
      out.write("</td>\r\n\t<td>");
      out.print( descn );
      out.write("</td>\r\n");

	out.println("</tr>");
}


      out.write("\r\n</table>\r\n<a href=\"index.jsp\">返回</a>\r\n</center>\r\n</body>\r\n</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 + -