📄 an_upload.jsp
字号:
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*,java.util.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>添加管理员</title>
</head>
<body>
<%!String tea_id;%>
<%tea_id=(String)session.getAttribute("teacher");%>
<%Calendar cal=Calendar.getInstance();
int year=cal.get(Calendar.YEAR);
int month=cal.get(Calendar.MONTH)+1;
int date=cal.get(Calendar.DATE);
int hour=cal.get(Calendar.HOUR_OF_DAY);
int minute=cal.get(Calendar.MINUTE);
String date1=year+"-"+month+"-"+date+"/"+hour+":"+minute;
//out.print(date1);
request.setCharacterEncoding("gbk");//设置通过request.getParameter得到的Form中元素的编码格式,可以显示汉字
String answer=request.getParameter("textarea");//通过request.getParameter方法得到Form中的元素("USERID,PASSWORD等")
%>
<%
Connection conn=null;
Statement stmt=null;
ResultSet rs=null;
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");//加载Sun的JDBC-ODBC桥驱动程序
}
catch(ClassNotFoundException ce){
out.println(ce.getMessage());
}
try{
conn=DriverManager.getConnection("jdbc:odbc:libwm");//使用DriverManager类的getConnection()方法来建立数据库连接
stmt=conn.createStatement();
String sql="INSERT INTO answers (回答教师编号,回答时间,回复)" + " VALUES ('"+tea_id+"','"+date1+"','"+answer+"')";
stmt.executeUpdate(sql);//执行sql语句更新数据库
response.sendRedirect("succ.jsp");//转向“succ.jsp”页
}catch(SQLException e){
out.print(e.getMessage());
}
finally{
stmt.close();//停止发送sql语句
conn.close();//关闭数据库连接
}
%>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -