edit.jsp
来自「jsp的技术教程」· JSP 代码 · 共 179 行
JSP
179 行
<%@ page language="java" import="java.sql.*" %>
<jsp:useBean id="workM" scope="page" class="test.faq" />
<%@ include file="../book_store/head.inc"%>
<%!
public String getStr(String str)
{
try
{
String temp_p=str;
byte[] temp_t=temp_p.getBytes("GBK");
String temp=new String(temp_t,"ISO8859_1");
return temp;
}
catch(Exception e)
{
}
return "null";
}
%>
<%if(session.getAttribute("username")==null){
response.sendRedirect("../member/login.jsp?url="+request.getRequestURI());
}
%>
<jsp:useBean id='clock' scope='page' class='dates.JspCalendar' type="dates.JspCalendar" />
<TABLE border=0 cellPadding=0 cellSpacing=0 width=760 align="center">
<TBODY>
<tr><td align="left" height=25><%if(session.getAttribute("username")!=null){out.println(session.getAttribute("username"));}%> 当前位置:<a href="../index.jsp">首页</a> -> <a href="index.jsp">论坛 </a> -> 修改贴子 </td>
<%@ include file="../member/date.inc"%>
</tr>
<TR bgColor=#3399ff>
<TD height=1 colspan="2"><IMG height=1 src="images/spacer.gif"
width=16></TD></TR>
<tr><td height=10 colspan="2"><IMG height=1 src="images/spacer.gif"
width=16></td></tr>
</TBODY></TABLE>
<table align="center" border="0" width="760" cellspacing="0" cellpadding="0" height="355">
<tr>
<td width="150" height="355" valign="top">
</td>
<td width="10" height="100%"></td>
<td width="1" height="100%" bgcolor="#3399ff"></td>
<td width="10" height="100%"></td>
<td width="589" height="331" valign="top" background="images/bg1.gif">
<table border="0" width="100%" cellspacing="0" cellpadding="0" height="307">
<tr>
<td width="100%" height="20" bgcolor="#3399ff"> <font color="#ffffff">修改贴子</font>
</td>
</tr>
<tr>
<td>
<%!
//boolean loginAttempt = false;
//if (loginAttempt)
// {
// out.print("fds");
// }else out.println("1212");
%>
<form name="form1" method="post" action="edit_ok.jsp">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td colspan="3" height="20"></td></tr>
<tr>
<td align="right" width="120" valign="top">说明:</td>
<td width="20"> </td>
<td width="450">
<ul type="square">
<li>不支持HTML,请用文本格式。所有输入的HTML标记,都会被还原!</li>
</ul>
</td>
</tr>
<%
String id,mode;
id=request.getParameter("id");
mode=request.getParameter("mode");
if(mode.equals("topic"))
{
mode="topic";
}
else
{
mode="reply";
}
String strSQL="SELECT * FROM "+mode+" where id="+id;
ResultSet RSa = workM.executeQuery(strSQL);
//out.println(strSQL);
while (RSa.next()) {
String a_author,title,aemail,content;
a_author=getStr(RSa.getString("author"));
title=getStr(RSa.getString("title"));
aemail=getStr(RSa.getString("email"));
content=getStr(RSa.getString("content"));
%>
<tr>
<td align="right">标题:</td>
<td width="20">*</td>
<td width="500">
<input type="hidden" name="id" value="<%=id%>">
<input type="hidden" name="mode" value="<%=mode%>">
<input type="text" name="title" size="64" value="<%=title%>">
</td>
</tr>
<tr>
<td align="right">作者:</td>
<td width="20">*</td>
<td width="500">
<input type="text" name="author" size="64" value="<%=session.getValue("username")%>" readonly>
</td>
</tr>
<tr>
<td align="right">作者的电子邮件:</td>
<td width="20"> </td>
<td width="500">
<input type="text" name="aemail" size="64" value="<%=aemail%>">
</td>
</tr>
<tr>
<td align="right" valign="top">内容:</td>
<td width="20" valign="top">*</td>
<td>
<textarea name="content" cols="64" rows="8"><%=content%></textarea>
</td>
</tr>
<tr>
<td align="right"> </td>
<td width="20"> </td>
<td align="right">
<input type="button" name="post" value="张贴" onclick="sub()">
</td>
</tr>
</table>
</form>
<%
}
RSa.close();
%>
</td>
</tr>
</table>
<script language="javascript">
function sub()
{
if(document.form1.title.value=="")
{
window.alert("请输入文章标题!");
document.form1.title.focus();
return false;
}
if(document.form1.author.value=="")
{
window.alert("请输入作者姓名!");
document.form1.author.focus();
return false;
}
if(document.form1.content.value=="")
{
window.alert("请输入文章内容!");
document.form1.content.focus();
return false;
}
document.form1.submit();
}
</script>
</td>
</tr>
</table>
<%@ include file="../member/footer.inc"%>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?