📄 post.jsp.htm
字号:
<%@page contentType="text/html;charset=gb2312"%>
<%@page import="java.sql.*"%>
<html>
<head>
<title>新发表或回复文章</title>
</head>
<body>
<%//防止某些用户不进行登陆,直接想进入此页面
if (session.getAttribute("username")==null){
response.sendRedirect("login1.jsp");
}%>
<%
//得到文章的标识ID
String id=request.getParameter("id");
//得到当前所在讨论区的编号bid
int bid=Integer.parseInt(request.getParameter("bid"));
//得到要回复文章的标识ID
int reid=Integer.parseInt(request.getParameter("reid"));
//接收登陆用户的身份等级信息rankid
int rankid=Integer.parseInt(request.getParameter("rankid"));
String boardtitle="";
if(bid==1) boardtitle="JSP技术";
if(bid==2) boardtitle="音乐星空";
String sql="";
//加载数据库驱动并用连接池连结数据库
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(ClassNotFoundException e)
{
out.print(e);
}
String strDirPath=application.getRealPath(request.getRequestURI());
strDirPath=strDirPath.substring(0,strDirPath.lastIndexOf('\\'))+"\\";
String url = "jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ="+strDirPath+"forum.mdb";
Connection conn = DriverManager.getConnection(url);
Statement stmt = conn.createStatement();
%>
<%
String hint="";
//此页面的提示信息
if(reid==0) hint="发布新贴子";
else hint="回复贴子";
%>
     <%=boardtitle%>>><%=hint%><p></p>
<table width="90%" align="center" cellpadding="3" cellspacing="1">
<form name="FM" method="post" action="chktodb.jsp">
<input type="hidden" name="bid" value="<%=bid%>">
<input type="hidden" name="reid" value="<%=reid%>">
<input type="hidden" name="rankid" value="<%=rankid%>">
<input type="hidden" name="exe" value="write">
<tr>
<td bgcolor="#009933" colspan=2>   <%=hint%>     
<a href="javascript:FM.submit();">确定</a>
      <a href="javascript:history.back();">取消</a>
</td>
</tr>
<%
//如果是发表新文章
if (reid==0){%>
<tr>
<td bgcolor="#efefef">标题</td>
<td bgcolor="#efefef"><input type="text" name="title"></td>
</tr>
<%}
//如果是回复文章,就查询要回复文章的标题
else{
sql="select Title from Articles where ID="+reid;
ResultSet rs=stmt.executeQuery(sql);
rs.next();
String title=rs.getString("Title");
%>
<tr>
<td bgcolor="#efefef">标题</td>
<td bgcolor="#efefef">Re <%=title%></td>
<tr>
<input type="hidden" name="title" value="Re <%=title%>">
<%rs.close();
}%>
<tr>
<td bgcolor="#efefef">心情</td>
<td bgcolor="#efefef">
<input type="radio" name="emotion" value="images/emotion/face0.gif" checked><img src="images/emotion/face0.gif">
<input type="radio" name="emotion" value="images/emotion/face1.gif"><img src="images/emotion/face1.gif">
<input type="radio" name="emotion" value="images/emotion/face2.gif"><img src="images/emotion/face2.gif">
<input type="radio" name="emotion" value="images/emotion/face3.gif"><img src="images/emotion/face3.gif">
<input type="radio" name="emotion" value="images/emotion/face4.gif"><img src="images/emotion/face4.gif">
<input type="radio" name="emotion" value="images/emotion/face5.gif"><img src="images/emotion/face5.gif">
<input type="radio" name="emotion" value="images/emotion/face6.gif"><img src="images/emotion/face6.gif">
<input type="radio" name="emotion" value="images/emotion/face7.gif"><img src="images/emotion/face7.gif">
<input type="radio" name="emotion" value="images/emotion/face8.gif"><img src="images/emotion/face8.gif">
<br>
<input type="radio" name="emotion" value="images/emotion/face9.gif"><img src="images/emotion/face9.gif">
<input type="radio" name="emotion" value="images/emotion/face10.gif"><img src="images/emotion/face10.gif">
<input type="radio" name="emotion" value="images/emotion/face11.gif"><img src="images/emotion/face11.gif">
<input type="radio" name="emotion" value="images/emotion/face12.gif"><img src="images/emotion/face12.gif">
<input type="radio" name="emotion" value="images/emotion/face13.gif"><img src="images/emotion/face13.gif">
<input type="radio" name="emotion" value="images/emotion/face14.gif"><img src="images/emotion/face14.gif">
<input type="radio" name="emotion" value="images/emotion/face15.gif"><img src="images/emotion/face15.gif">
<input type="radio" name="emotion" value="images/emotion/face16.gif"><img src="images/emotion/face16.gif">
<input type="radio" name="emotion" value="images/emotion/face17.gif"><img src="images/emotion/face17.gif">
</td>
</tr>
<tr>
<td bgcolor="#efefef" align="center">内容</td>
<td bgcolor="#efefef"><textarea name="content" rows="10" cols="100"></textarea></td>
</tr>
</form>
</table>
<%//关闭连接
stmt.close();
conn.close();
%>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -