search_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 search_0002ejsp_jsp extends HttpJspBase {
- static {
- }
- public search_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="/search.jsp";from=(0,48);to=(1,0)]
- out.write("rn");
- // end
- // HTML // begin [file="/search.jsp";from=(1,29);to=(15,0)]
- out.write("<head>rn <SCRIPT language="JavaScript">rnfunction a() {rnrntif(form1.keywords.value==""){rnttalert("用户名不能为空,请确定后重新输入");rnttform1.keywords.focus();rnttreturn false;rnt}rnrntreturn true;rn}</script></head>rn<HTML><BODY >rn<br>rn");
- // end
- // begin [file="/search.jsp";from=(15,2);to=(61,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 student WHERE stu_id LIKE '%" + str + "%'");
- out.print("<table width='100%' cellspacing='0' cellpadding='4' rules='all' bordercolor='#CC9966' border='1' id='dg_rxkb' style='background-color:White;border-color:#CC9966;border-width:1px;border-style:None;width:99%;border-collapse:collapse;'>");
- 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>");
- while(rs.next()){
- out.print("<tr align='center'><TD>"+rs.getString("stu_name")+"</TD>");
- out.print("<TD>"+rs.getString("stu_id")+"</TD>");
- out.print("<TD>"+rs.getString("sex")+"</TD>");
- out.print("<TD>"+rs.getString("dept")+"</TD>");
- out.print("<TD>"+rs.getString("mz")+"</TD>");
- out.print("<TD>"+rs.getString("zzmm")+"</TD>");
- }
- out.print("</TABLE>");
- }
- catch(SQLException e){
- System.out.println(e.getMessage());
- }
- finally{
- stmt.close();
- conn.close();
- }
- // end
- // HTML // begin [file="/search.jsp";from=(61,2);to=(70,46)]
- out.write("rn<br><br>rn <FORM name="form1" Action="search.jsp" Method="POST">rn <table width="100%" cellspacing="0" cellpadding="4" rules="all" bordercolor="#CC9966" border="1" id="dg_rxkb" style="background-color:White;border-color:#CC9966;border-width:1px;border-style:None;width:99%;border-collapse:collapse;">rnrn<tr>rn <td colspan="2"><div align="center" ><font size="5" color="red">查找信息</strong></font></div></td>rn </tr>rn<tr ><td align="center"><font color="000000" size="4">请输入学号:</td>rn<td><INPUT Type="Text" Name="keywords" Value="");
- // end
- // begin [file="/search.jsp";from=(70,49);to=(70,52)]
- out.print(str);
- // end
- // HTML // begin [file="/search.jsp";from=(70,54);to=(79,0)]
- out.write(""></td></tr>rn<tr><td height="35" colspan="2"><div align="center"><INPUT Type=Submit Value=" 查找" onClick="return a()"></td></tr></table>rn</FORM>rn<br>rn<br>rn<br>rn<p align=center>rn<img src="img/boshi.jpg">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);
- }
- }
- }