article.jsp

来自「jsp的技术教程」· JSP 代码 · 共 125 行

JSP
125
字号
<%@ include file="../book_store/head.inc"%> 
<%@ page language="java" import="java.sql.*" %>
<jsp:useBean id="workM" scope="page" class="test.faq" />
<jsp:useBean id='clock' scope='page' class='dates.JspCalendar' type="dates.JspCalendar" />      
<%!
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";
}
%>                        
<TABLE border=0 cellPadding=0 cellSpacing=0 width=760 align="center">
  <TBODY>
  <tr><td align="left" height=25>当前位置:<a href="../index.jsp">首页</a> -&gt; <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">                  
          <tr>                  
            <td colspan="3" width="100%" height="20" bgcolor="#3399ff">&nbsp;<font color="#ffffff">论坛  -&gt; 详细查看</font>
			</td>
		  </tr>
		  <tr>
		 
		  <td align="center" colspan='3' valign="top">


	<%
		String id;
		id=request.getParameter("id");
		String strSQL="SELECT * FROM topic where id="+id;
		ResultSet RSa = workM.executeQuery(strSQL);
		//out.println(strSQL);
		
		while (RSa.next()) {
			String a_author;
			int topic_id;
			topic_id=RSa.getInt("id");
			a_author=getStr(RSa.getString("author"));
			out.print("<br><b><font color=red>"+getStr(RSa.getString("title"))+"</font></b><br>"+a_author+" "+RSa.getDate("date")+"<br><br></td></tr><tr><td colspan='3' align='right'>");
			if(a_author.equals(session.getValue("username")))
			{
				out.print("<a href=edit.jsp?mode=topic&id="+topic_id+">编  辑</a>&nbsp;&nbsp;<a href=delete.jsp?mode=topic&id="+topic_id+">删  除</a> &nbsp;&nbsp;");
			}
			out.print("<a href=reply.jsp?id="+id+">回  复</a> &nbsp;&nbsp;<a href=index.jsp>返 回</a></td></tr><tr><td colspan='3' height='1' bgcolor='#3399ff'></td></tr><tr><td width='5%'></td>");
			out.print("<td><br>作者:"+a_author+"<br><br>");
			out.print(getStr(RSa.getString("content")));

		}
		RSa.close();

	%>
	

			</td>
			 <td width="5%"></td>
		  </tr>
		   
		   <%
	//	String id;
//		id=request.getParameter("id");
		String strRe="SELECT * FROM reply where topicID="+id;
		ResultSet RSr = workM.executeQuery(strRe);
		//out.println(strSQL);
		
		while (RSr.next()) {
		%>
		
		<%
			String a_author,t_id;
			t_id=RSr.getString("id");
			a_author=getStr(RSr.getString("author"));
			out.println("<tr><td colspan='3' height='1' bgcolor='#3399ff'></td></tr>");
			out.println("<tr><td colspan='3' align='right'>");
			if(a_author.equals(session.getValue("username")))
			{
				out.print("<a href=edit.jsp?mode=reply&id="+t_id+">编  辑</a>&nbsp;&nbsp;<a href=delete.jsp?mode=reply&id="+t_id+">删  除</a> &nbsp;&nbsp;");
			}
			out.print("<a href=reply.jsp?id="+id+">回  复</a> &nbsp;&nbsp;<a href=index.jsp>返 回</a></td></tr>");
			out.println("<tr><td align=center colspan='3' valign=top>");
			out.print("<br><b>"+getStr(RSr.getString("title"))+"</b><br>"+a_author+" "+RSr.getDate("date")+"<br><br></td></tr>");
			out.print("<tr><td width='5%'></td>");
			out.print("<td><br>作者:"+a_author+"<br><br>");
			out.print(getStr(RSr.getString("content")));
		%>
			</td>
			 <td width="5%"></td>
			 </tr>
		<%
		}
		RSr.close();

	%>
		   
        </table>                  
        </td>
    </tr>
  </table>
<%@ include file="../member/footer.inc"%>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?