📄 teacher_noticemanager.jsp
字号:
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" 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>
<style type="text/css">
<!--
.STYLE3 {color: #0000FF; }
#Layer1 {
position:absolute;
width:200px;
height:115px;
z-index:1;
left: 158px;
top: 19px;
}
#Layer2 {
position:absolute;
width:306px;
height:116px;
z-index:1;
left: 464px;
top: 19px;
}
#Layer3 {
position:absolute;
width:110px;
height:251px;
z-index:2;
left: 334px;
top: 33px;
}
#Layer4 {
position:absolute;
width:593px;
height:251px;
z-index:3;
left: 383px;
top: 30px;
}
#Layer5 {
position:absolute;
width:797px;
height:132px;
z-index:2;
left: 158px;
top: 246px;
}
.STYLE4 {
font-size: 18px;
font-weight: bold;
color: #0000FF;
}
.STYLE5 {color: #FF0000}
.STYLE6 {font-size: 18}
-->
</style>
</head>
<body>
<%
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String driver = "jdbc:odbc:netteach";
//如果是采用windwos验证方式,则采用下面的语句连接
//Connection conn = DriverManager.getConnection(driver);
//如果采用SQL Server验证方式,则采用下面语句,其中sa是用户名,密码为空,如果用户设置了密码,后面的引号中写入密码
Connection conn = DriverManager.getConnection(driver);
Statement stmt = conn.createStatement();
String user_id=(String)session.getAttribute("user_id");
String sql="select * from n_course where user_id='"+user_id+"'";
%>
<form name=form method=post action="teacher_noticeManager.jsp">
<table width="668" height="270" border="1" align="center" cellpadding="2" cellspacing="1" bordercolor="#DDF2F8">
<tr>
<td width="656" height="30"><div align="center" class="STYLE4">发布课程公告</div></td>
</tr>
<tr>
<td height="30"><span class="STYLE5">请选择您发布公告的课程ID:</span>
<label>
<select name="select_courseid" value="select_courseid">
<% if(user_id == null)
{ }
else{
ResultSet rs=stmt.executeQuery(sql);
while(rs.next())
{
String courseid=rs.getString("course_id");
%>
<option value="<%=courseid%>"><%=courseid%></option>
<% }
%>
</select>
</label></td>
</tr>
<tr>
<td height="29"><span class="STYLE5">请发布的公告内容:
<label></label>
</span> <label> </label></td>
</tr>
<tr>
<td height="140"><textarea name="notice" cols="50" rows="10"></textarea></td>
</tr>
<tr>
<td height="27"><label></label>
<div align="center">
<input type=submit name=submit value="提交" />
<input name="reset" type="submit" id="reset" value="重置" />
</div></td>
</tr>
</table>
<p>
<label>
<div align="center" class="STYLE6">
</label>
</form>
<%
try{
String n_courseid = request.getParameter("select_courseid");
String n_notice = request.getParameter("notice");
byte [] tmpbyte = n_notice.getBytes("ISO8859_1");
n_notice = new String(tmpbyte);
java.util.Date dt = new java.util.Date();
String noticetime = String.valueOf(1900+dt.getYear())+"-"+String.valueOf(1+dt.getMonth())+"-"+String.valueOf(dt.getDate());
stmt.executeUpdate("insert into n_notice values ('"+n_notice+"','"+noticetime+"','"+n_courseid+"')");
}
catch(Exception e){
out.println(e);
}
%>
<% }
%>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -