stu1_0002ejsp_jsp.java
资源名称:JSP02.rar [点击查看]
上传用户:top0756
上传日期:2022-08-11
资源大小:6501k
文件大小:6k
源码类别:
Jsp/Servlet
开发平台:
VBScript
- import java.sql.*;
- import javax.servlet.*;
- import javax.servlet.http.*;
- import javax.servlet.jsp.*;
- import org.apache.jasper.runtime.*;
- public class stu1_0002ejsp_jsp extends HttpJspBase {
- static {
- }
- public stu1_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="/stu1.jsp";from=(0,48);to=(1,0)]
- out.write("rn");
- // end
- // HTML // begin [file="/stu1.jsp";from=(1,29);to=(4,0)]
- out.write("rn<HTML><BODY ><br><br><br><br>rnrn");
- // end
- // begin [file="/stu1.jsp";from=(4,2);to=(51,0)]
- Connection conn = null;
- Statement stmt = null;
- ResultSet rs = null;
- try{
- Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
- }
- catch(ClassNotFoundException ce){
- out.println(ce.getMessage());
- }
- request.setCharacterEncoding("GBK");
- String str = request.getParameter("keywords");
- if( str == null)
- str = "";
- else
- try{
- conn=DriverManager.getConnection("jdbc:odbc:dsn112");
- stmt=conn.createStatement();
- rs=stmt.executeQuery("SELECT * FROM stu WHERE name LIKE '%" + str + "%'");
- out.print("<TABLE align='center' width='70%' BORDER='0'>");
- out.print("<tr bgcolor='EcEcff' align='center'><TD>学期号</TD>");
- out.print("<TD>课程号</TD>");
- out.print("<TD>课程名</TD>");
- out.print("<TD>学分</TD>");
- out.print("<TD>成绩</TD>");
- out.print("<TD>重修成绩</TD>");
- out.print("<TD>主讲老师</TD></TR>");
- while(rs.next()){
- out.print("<tr bgcolor='FFEFEF' align='center'><TD>"+rs.getString("xq_id")+"</TD>");
- out.print("<TD>"+rs.getString("co_id")+"</TD>");
- out.print("<TD>"+rs.getString("co_name")+"</TD>");
- out.print("<TD>"+rs.getString("credit_hour")+"</TD>");
- out.print("<TD>"+rs.getString("cj")+"</TD>");
- out.print("<TD>"+rs.getString("cxcj")+"</TD>");
- out.print("<TD>"+rs.getString("teacher")+"</TD></TR>");
- }
- out.print("</TABLE>");
- }
- catch(SQLException e){
- System.out.println(e.getMessage());
- }
- finally{
- stmt.close();
- conn.close();
- }
- // end
- // HTML // begin [file="/stu1.jsp";from=(51,2);to=(61,46)]
- 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="");
- // end
- // begin [file="/stu1.jsp";from=(61,49);to=(61,52)]
- out.print(str);
- // end
- // HTML // begin [file="/stu1.jsp";from=(61,54);to=(65,0)]
- 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");
- // 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);
- }
- }
- }