stu1_0002ejsp_jsp.java
上传用户:top0756
上传日期:2022-08-11
资源大小:6501k
文件大小:6k
源码类别:

Jsp/Servlet

开发平台:

VBScript

  1. import java.sql.*;
  2. import javax.servlet.*;
  3. import javax.servlet.http.*;
  4. import javax.servlet.jsp.*;
  5. import org.apache.jasper.runtime.*;
  6. public class stu1_0002ejsp_jsp extends HttpJspBase {
  7.     static {
  8.     }
  9.     public stu1_0002ejsp_jsp( ) {
  10.     }
  11.     private static boolean _jspx_inited = false;
  12.     public final void _jspx_init() throws org.apache.jasper.runtime.JspException {
  13.     }
  14.     public void _jspService(HttpServletRequest request, HttpServletResponse  response)
  15.         throws java.io.IOException, ServletException {
  16.         JspFactory _jspxFactory = null;
  17.         PageContext pageContext = null;
  18.         HttpSession session = null;
  19.         ServletContext application = null;
  20.         ServletConfig config = null;
  21.         JspWriter out = null;
  22.         Object page = this;
  23.         String  _value = null;
  24.         try {
  25.             if (_jspx_inited == false) {
  26.                 synchronized (this) {
  27.                     if (_jspx_inited == false) {
  28.                         _jspx_init();
  29.                         _jspx_inited = true;
  30.                     }
  31.                 }
  32.             }
  33.             _jspxFactory = JspFactory.getDefaultFactory();
  34.             response.setContentType("text/html;charset=gb2312");
  35.             pageContext = _jspxFactory.getPageContext(this, request, response,
  36.              "", true, 8192, true);
  37.             application = pageContext.getServletContext();
  38.             config = pageContext.getServletConfig();
  39.             session = pageContext.getSession();
  40.             out = pageContext.getOut();
  41.             // HTML // begin [file="/stu1.jsp";from=(0,48);to=(1,0)]
  42.                 out.write("rn");
  43.             // end
  44.             // HTML // begin [file="/stu1.jsp";from=(1,29);to=(4,0)]
  45.                 out.write("rn<HTML><BODY ><br><br><br><br>rnrn");
  46.             // end
  47.             // begin [file="/stu1.jsp";from=(4,2);to=(51,0)]
  48.                 
  49.                 Connection conn = null;
  50.                 Statement stmt = null;
  51.                 ResultSet rs = null;
  52.                 try{
  53.                  Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  54.                 }
  55.                 catch(ClassNotFoundException ce){
  56.                  out.println(ce.getMessage());
  57.                 }
  58.                 request.setCharacterEncoding("GBK");
  59.                 String str = request.getParameter("keywords");
  60.                 if( str == null)
  61.                  str = "";
  62.                       else
  63.                 try{
  64.                  conn=DriverManager.getConnection("jdbc:odbc:dsn112");
  65.                  stmt=conn.createStatement();
  66.                         rs=stmt.executeQuery("SELECT * FROM stu WHERE name LIKE '%" + str + "%'");
  67.                         out.print("<TABLE  align='center' width='70%'  BORDER='0'>");
  68.                          out.print("<tr bgcolor='EcEcff' align='center'><TD>学期号</TD>");
  69.                        out.print("<TD>课程号</TD>");
  70.                  out.print("<TD>课程名</TD>");
  71.                                 out.print("<TD>学分</TD>");
  72.                                 out.print("<TD>成绩</TD>");
  73.                                 out.print("<TD>重修成绩</TD>");
  74.                        out.print("<TD>主讲老师</TD></TR>");
  75.                  while(rs.next()){
  76.                  out.print("<tr bgcolor='FFEFEF' align='center'><TD>"+rs.getString("xq_id")+"</TD>");
  77.                  out.print("<TD>"+rs.getString("co_id")+"</TD>");
  78.                  out.print("<TD>"+rs.getString("co_name")+"</TD>");
  79.                  out.print("<TD>"+rs.getString("credit_hour")+"</TD>");
  80.                                 out.print("<TD>"+rs.getString("cj")+"</TD>");
  81.                                  out.print("<TD>"+rs.getString("cxcj")+"</TD>");
  82.                  out.print("<TD>"+rs.getString("teacher")+"</TD></TR>");
  83.                  }
  84.                  out.print("</TABLE>");
  85.                 
  86.                 }
  87.                 catch(SQLException e){
  88.                  System.out.println(e.getMessage());
  89.                 }
  90.                 finally{
  91.                  stmt.close();
  92.                  conn.close();
  93.                 }
  94.                 
  95.             // end
  96.             // HTML // begin [file="/stu1.jsp";from=(51,2);to=(61,46)]
  97.                 out.write("rn<br><br>rn<br><br>rn <FORM Action="" Method="POST">rn<table width="70%"  border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#A5C1CC">rnrn<tr bgcolor="#fcd56c">rn      <td height="40" colspan="2"><div align="center" ><font  size="5" color="#000000"><strong>查找信息</strong></font></div></td>rn    </tr>rn<tr ><td><font color="000000" size="4">输入姓名关键字:</td>rn<td><INPUT Type="Text" Name="keywords" Value="");
  98.             // end
  99.             // begin [file="/stu1.jsp";from=(61,49);to=(61,52)]
  100.                 out.print(str);
  101.             // end
  102.             // HTML // begin [file="/stu1.jsp";from=(61,54);to=(65,0)]
  103.                 out.write(""></td></tr>rn<tr bgcolor="#fcd56c"><td  height="35" colspan="2"><div align="center"><INPUT Type=Submit Value=" 查找"></td></tr></table>rn</FORM>rn</BODY></HTML>rn");
  104.             // end
  105.         } catch (Throwable t) {
  106.             if (out != null && out.getBufferSize() != 0)
  107.                 out.clearBuffer();
  108.             if (pageContext != null) pageContext.handlePageException(t);
  109.         } finally {
  110.             if (_jspxFactory != null) _jspxFactory.releasePageContext(pageContext);
  111.         }
  112.     }
  113. }