insert_0002ejsp_jsp.java
资源名称:JSP02.rar [点击查看]
上传用户:top0756
上传日期:2022-08-11
资源大小:6501k
文件大小:6k
源码类别:
Jsp/Servlet
开发平台:
VBScript
- import java.sql.*;
- import proj112.ISOtoGb2312;
- import javax.servlet.*;
- import javax.servlet.http.*;
- import javax.servlet.jsp.*;
- import org.apache.jasper.runtime.*;
- public class insert_0002ejsp_jsp extends HttpJspBase {
- static {
- }
- public insert_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=GBK");
- pageContext = _jspxFactory.getPageContext(this, request, response,
- "", true, 8192, true);
- application = pageContext.getServletContext();
- config = pageContext.getServletConfig();
- session = pageContext.getSession();
- out = pageContext.getOut();
- // HTML // begin [file="/insert.jsp";from=(0,48);to=(2,0)]
- out.write("rnrn");
- // end
- // HTML // begin [file="/insert.jsp";from=(2,32);to=(3,0)]
- out.write("rn");
- // end
- // HTML // begin [file="/insert.jsp";from=(3,28);to=(4,0)]
- out.write("rn");
- // end
- // HTML // begin [file="/insert.jsp";from=(4,41);to=(17,0)]
- 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");
- // end
- // begin [file="/insert.jsp";from=(17,2);to=(21,1)]
- String idvalue = request.getParameter("name").trim();
- String capvlu = null;
- // end
- // HTML // begin [file="/insert.jsp";from=(21,3);to=(26,0)]
- out.write("rn<br><br>rn<font color="8282DC" size="5"><center>rnrn</font></center><br><br>rn");
- // end
- // begin [file="/insert.jsp";from=(26,2);to=(50,1)]
- Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); //载入驱动程序类别
- Connection con = DriverManager.getConnection("jdbc:odbc:dsn112"); //建立数据库链接
- Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
- ResultSet.CONCUR_READ_ONLY);
- String strSQL;
- strSQL = "INSERT INTO Info(stu_id, name, sex, " +
- "age,dept, ruxdate,tel,address,stu_password) Values ('" +
- ISOtoGb2312.convert( request.getParameter("stu_id")) + "','" +
- ISOtoGb2312.convert( request.getParameter("name")) + "','" +
- ISOtoGb2312.convert( request.getParameter("sex")) + "','" +
- ISOtoGb2312.convert( request.getParameter("age")) + "','" +
- ISOtoGb2312.convert( request.getParameter("dept")) + "','" +
- ISOtoGb2312.convert( request.getParameter("ruxdate")) + "','" +
- ISOtoGb2312.convert( request.getParameter("tel")) + "','" +
- ISOtoGb2312.convert( request.getParameter("address")) + "','" +
- ISOtoGb2312.convert( request.getParameter("stu_password")) + "')";
- stmt.executeUpdate(strSQL);
- ResultSet rs; //建立ResultSet(结果集)对象
- rs = stmt.executeQuery("SELECT * FROM Info"); //执行SQL语句
- rs.close(); //关闭ResultSet对象
- stmt.close(); //关闭Statement对象
- con.close(); //关闭Connection对象
- // end
- // HTML // begin [file="/insert.jsp";from=(50,3);to=(67,0)]
- 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");
- // 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);
- }
- }
- }