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

Jsp/Servlet

开发平台:

VBScript

  1. import java.sql.*;
  2. import proj112.ISOtoGb2312;
  3. import javax.servlet.*;
  4. import javax.servlet.http.*;
  5. import javax.servlet.jsp.*;
  6. import org.apache.jasper.runtime.*;
  7. public class insert_0002ejsp_jsp extends HttpJspBase {
  8.     static {
  9.     }
  10.     public insert_0002ejsp_jsp( ) {
  11.     }
  12.     private static boolean _jspx_inited = false;
  13.     public final void _jspx_init() throws org.apache.jasper.runtime.JspException {
  14.     }
  15.     public void _jspService(HttpServletRequest request, HttpServletResponse  response)
  16.         throws java.io.IOException, ServletException {
  17.         JspFactory _jspxFactory = null;
  18.         PageContext pageContext = null;
  19.         HttpSession session = null;
  20.         ServletContext application = null;
  21.         ServletConfig config = null;
  22.         JspWriter out = null;
  23.         Object page = this;
  24.         String  _value = null;
  25.         try {
  26.             if (_jspx_inited == false) {
  27.                 synchronized (this) {
  28.                     if (_jspx_inited == false) {
  29.                         _jspx_init();
  30.                         _jspx_inited = true;
  31.                     }
  32.                 }
  33.             }
  34.             _jspxFactory = JspFactory.getDefaultFactory();
  35.             response.setContentType("text/html; charset=GBK");
  36.             pageContext = _jspxFactory.getPageContext(this, request, response,
  37.              "", true, 8192, true);
  38.             application = pageContext.getServletContext();
  39.             config = pageContext.getServletConfig();
  40.             session = pageContext.getSession();
  41.             out = pageContext.getOut();
  42.             // HTML // begin [file="/insert.jsp";from=(0,48);to=(2,0)]
  43.                 out.write("rnrn");
  44.             // end
  45.             // HTML // begin [file="/insert.jsp";from=(2,32);to=(3,0)]
  46.                 out.write("rn");
  47.             // end
  48.             // HTML // begin [file="/insert.jsp";from=(3,28);to=(4,0)]
  49.                 out.write("rn");
  50.             // end
  51.             // HTML // begin [file="/insert.jsp";from=(4,41);to=(17,0)]
  52.                 out.write("rn<html>rn<head>rn<title>rn添加数据rn</title>rn</head>rn<body text="#808080" link="#FF99CC" vlink="#FF8080" alink="#FF99CC" topmargin="0" leftmargin="0"><style>rn<!--rnBODY {SCROLLBAR-FACE-COLOR: #FFFFFF; SCROLLBAR-HIGHLIGHT-COLOR: #FFFFFF; SCROLLBAR-SHADOW-COLOR: #FFFFFF; SCROLLBAR-3DLIGHT-COLOR: #FFFFFF; SCROLLBAR-ARROW-COLOR:  #FFAAAA; SCROLLBAR-TRACK-COLOR: #FFFFFF; SCROLLBAR-DARKSHADOW-COLOR: #FFFFFF; }rn-->rn</style>rnrn");
  53.             // end
  54.             // begin [file="/insert.jsp";from=(17,2);to=(21,1)]
  55.                 
  56.                   String idvalue = request.getParameter("name").trim();
  57.                   String capvlu = null;
  58.                 
  59.                  
  60.             // end
  61.             // HTML // begin [file="/insert.jsp";from=(21,3);to=(26,0)]
  62.                 out.write("rn<br><br>rn<font color="8282DC" size="5"><center>rnrn</font></center><br><br>rn");
  63.             // end
  64.             // begin [file="/insert.jsp";from=(26,2);to=(50,1)]
  65.                 
  66.                 Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); //载入驱动程序类别
  67.                 Connection con = DriverManager.getConnection("jdbc:odbc:dsn112"); //建立数据库链接
  68.                 Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
  69.                  ResultSet.CONCUR_READ_ONLY);
  70.                 String strSQL;
  71.                 strSQL = "INSERT INTO Info(stu_id, name, sex, " +
  72.                   "age,dept, ruxdate,tel,address,stu_password) Values ('" +
  73.                   ISOtoGb2312.convert( request.getParameter("stu_id")) + "','" +
  74.                   ISOtoGb2312.convert( request.getParameter("name")) + "','" +
  75.                   ISOtoGb2312.convert( request.getParameter("sex")) +  "','" +
  76.                   ISOtoGb2312.convert( request.getParameter("age")) + "','" +
  77.                                           ISOtoGb2312.convert( request.getParameter("dept")) + "','" +
  78.                                           ISOtoGb2312.convert( request.getParameter("ruxdate")) + "','" +
  79.                                           ISOtoGb2312.convert( request.getParameter("tel")) + "','" +
  80.                                           ISOtoGb2312.convert( request.getParameter("address")) + "','" +
  81.                         ISOtoGb2312.convert( request.getParameter("stu_password")) + "')";
  82.                  stmt.executeUpdate(strSQL);
  83.                 ResultSet rs; //建立ResultSet(结果集)对象
  84.                 rs = stmt.executeQuery("SELECT * FROM Info"); //执行SQL语句
  85.                 
  86.                 rs.close(); //关闭ResultSet对象
  87.                  stmt.close(); //关闭Statement对象
  88.                  con.close();  //关闭Connection对象
  89.                 
  90.             // end
  91.             // HTML // begin [file="/insert.jsp";from=(50,3);to=(67,0)]
  92.                 out.write("rn        <script language="JavaScript">rn        ttalert("添加成功");rn        ttlocation.href='add.jsp'rn                 </script>rnrnrnrn<CENTER>rnrnrn</CENTER><center>rn<h3><a href="add.jsp">返回</a></h3></center>rn</body>rn</html>rnrnrn");
  93.             // end
  94.         } catch (Throwable t) {
  95.             if (out != null && out.getBufferSize() != 0)
  96.                 out.clearBuffer();
  97.             if (pageContext != null) pageContext.handlePageException(t);
  98.         } finally {
  99.             if (_jspxFactory != null) _jspxFactory.releasePageContext(pageContext);
  100.         }
  101.     }
  102. }