guestbook.jsp
上传用户:jhtang88
上传日期:2014-01-27
资源大小:28528k
文件大小:7k
源码类别:

Jsp/Servlet

开发平台:

Java

  1. <%@ page contentType="text/html;charset=gb2312"%>
  2. <%@ page import = "java.net.URLEncoder"%>
  3. <%@ page import = "com.redmoon.oa.db.PageQuery"%>
  4. <html>
  5. <head>
  6. <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
  7. <title>镇江GIS黄页系统</title>
  8. <link href="common.css" rel="stylesheet" type="text/css">
  9. </head>
  10. <body leftmargin="0" topmargin="5">
  11. <%@ include file="inc/inc.jsp"%>
  12. <jsp:useBean id="fchar" scope="page" class="cn.js.fan.util.StrUtil"/>
  13. <jsp:useBean id="conn" scope="page" class="com.redmoon.oa.db.Conn"/>
  14. <jsp:setProperty name="conn" property="POOLNAME" value="ttoa"/>
  15. <jsp:useBean id="privilege" scope="page" class="com.redmoon.oa.pvg.Privilege"/>
  16. <table width="494" border="0" align="center" cellpadding="0" cellspacing="0">
  17.   <tr> 
  18.     <td height="23" valign="bottom" background="images/tab-b-top.gif">     <span class="right-title">留 
  19.       言 簿</span></td>
  20.   </tr>
  21.   <tr> 
  22.     <td valign="top" background="images/tab-b-back.gif">
  23.         <%
  24. String sql = "";
  25. String content = fchar.UnicodeToGB(request.getParameter("content"));
  26. if ((content!=null) && (!content.equals("")))
  27. {
  28. String ip = request.getRemoteAddr();
  29. sql = "insert into guestbook (person,ip,content) values ("+fchar.sqlstr(privilege.getUser(request))+","+fchar.sqlstr(ip)+","+fchar.sqlstr(content)+")";
  30. if (conn.executeUpdate(sql)==0)
  31. {
  32. conn.close();
  33. conn = null;
  34. out.println(fchar.makeErrMsg("留言失败,请检查留言内容是否超出了有效长度!"));
  35. return;
  36. }
  37. }
  38. if (conn!=null)
  39. {
  40. conn.close();
  41. conn = null;
  42. }
  43. %>
  44.         <%
  45. sql = "select * from guestbook order by lydate desc";
  46. int pagesize = 5;
  47. PageQuery pagebean = new PageQuery("ttoa");
  48. pagebean.setPageSize(pagesize);
  49. String Query = fchar.getNullString(request.getParameter("Query"));
  50. if (!Query.equals(""))
  51. sql = Query;
  52. ResultSet rs = pagebean.myQuery(sql,request) ; 
  53. pagebean.PageLegend(response);
  54. int curpage,totalpages;
  55. curpage = pagebean.getCurrentPages();
  56. totalpages = pagebean.getTotalPages();
  57. if (totalpages==0)
  58. {
  59. curpage = 1;
  60. totalpages = 1;
  61. }
  62. %>
  63.       <table width="90%" border="0">
  64.         <tr> 
  65.           <td height="5"></td>
  66.         </tr>
  67.       </table> 
  68.       <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
  69.         <tr> 
  70.           <td width="47"><img src="images/title1-l.gif" width="47" height="25"></td>
  71.           <td valign="top" background="images/title1-back.gif"><div align="center" class="title1">找到符合条件的记录 
  72.               <b><%=pagebean.getTotal() %></b> 条 每页显示 <b><%=pagebean.getPageSize() %></b> 
  73.               条 页次 <b><%=curpage %>/<%=totalpages %></b></div></td>
  74.           <td width="47"><img src="images/title1-r.gif" width="47" height="25"></td>
  75.         </tr>
  76.       </table> 
  77.       <br>
  78.       <%
  79. try
  80. {
  81.   int i = 0;
  82.   if (rs!=null )
  83.   {
  84.     if (pagebean.getTotalPages()>0)
  85. {
  86. do
  87. {
  88.   i++;
  89. %>
  90.       <table width="98%" border="0" align="center" cellpadding="2" cellspacing="0" class="stable">
  91.         <tr> 
  92.           <td width="27%" height="17" valign="bottom" bgcolor="#C4DAFF" class="stable"> 用户:<%=fchar.toHtml(rs.getString("person"))%> </td>
  93.           <td width="73%" valign="bottom" bgcolor="#C4DAFF" class="stable">留言日期:<%=rs.getDate("lydate")%></td>
  94.         </tr>
  95.         <tr> 
  96.           <td colspan="2" bgcolor="#EEEEEE" class="stable"> <%=fchar.toHtml(rs.getString("content"))%><br> <%
  97.   String reply = fchar.getNullString(rs.getString("reply"));
  98.   if (!reply.equals(""))
  99.   {
  100.   %> <font color="#F09F6F">回复:</font><%=fchar.toHtml(rs.getString("reply"))%> <br>
  101.             回复日期:<%=rs.getDate("redate")%> <% } %> </td>
  102.         </tr>
  103.       </table><br>
  104.       <%
  105. }
  106. while(i<pagesize && rs.next());
  107. }
  108. else
  109. out.println(fchar.p_center("暂无留言!"));
  110.   }
  111.   else
  112. out.println(fchar.p_center("暂无留言!"));
  113.   
  114. }
  115. catch(SQLException e)
  116. {
  117.   out.print("出错: ");
  118.   out.print(e);
  119.   out.print(e.getMessage());
  120. }
  121. if (rs!=null)
  122. {
  123. rs.close();
  124. rs = null;
  125. }
  126. pagebean.clear();
  127. %>
  128.       <table width="87%" border="0" cellspacing="1" cellpadding="3" align="center" class="9black">
  129.         <tr> 
  130.           <td height="23"> <div align="right"> 
  131.               <%
  132.   String querystr = "";
  133.   %>
  134.               <%if(!pagebean.getFirstPage().equals("none")) {%>
  135.               <a href="guestbook.jsp?<%=pagebean.getFirstPage()+querystr%>"><img src="images/first.gif" width="41" height="12" border="0"></a> 
  136.               <% }
  137.     if(!pagebean.getPrevPage().equals("none")){
  138.      %>
  139.               &nbsp;<a href="guestbook.jsp?<%=pagebean.getPrevPage()+querystr%>"><img src="images/forward.gif" width="47" height="12" border="0"></a> 
  140.               <% } 
  141.   if(!pagebean.getNextPage().equals("none")){%>
  142.               &nbsp;<a href="guestbook.jsp?<%=pagebean.getNextPage()+querystr%>"><img src="images/next.gif" width="47" height="12" border="0"></a> 
  143.               <% }
  144.                   if(!pagebean.getLastPage().equals("none")){   %>
  145.               &nbsp;<a href="guestbook.jsp?<%=pagebean.getLastPage()+querystr%>"><img src="images/last.gif" width="41" height="12" border="0"></a> 
  146.               <% }%>
  147.               &nbsp;</div></td>
  148.         </tr>
  149.       </table>
  150.       <br> <table width="409" height="192" border="0" align="center" background="">
  151.         <form name="form1" action="guestbook.jsp" method="post" onSubmit="return form1_onsubmit()">
  152.           <tr> 
  153.             <td width="403" valign="top"> <table width="98%" height="150" border="0" cellpadding="1" cellspacing="0">
  154.                 <tr> 
  155.                   <td width="20%" height="25">&nbsp;</td>
  156.                   <td height="25" colspan="2">&nbsp;</td>
  157.                 </tr>
  158.                 <tr> 
  159.                   <td>留言<br>
  160.                     内容</td>
  161.                   <td colspan="2"><textarea name="content" cols="50" rows="8"></textarea> 
  162.                   </td>
  163.                 </tr>
  164.                 <tr> 
  165.                   <td>&nbsp;</td>
  166.                   <td width="30%"> <div align="left"> </div></td>
  167.                   <td width="50%"><input name="submit" type="submit" class="stable" value="发送留言"></td>
  168.                 </tr>
  169.               </table></td>
  170.           </tr>
  171.         </form>
  172.       </table></td>
  173.   </tr>
  174.   <tr> 
  175.     <td height="9"><img src="images/tab-b-bot.gif" width="494" height="9"></td>
  176.   </tr>
  177. </table>
  178. </body>
  179. <SCRIPT language=javascript id=clientEventHandlersJS>
  180. <!--
  181. function form1_onsubmit()
  182. {
  183. if (form1.content.value=="")
  184. {
  185. alert("留言内容不能为空!");
  186. return false;
  187. }
  188. }
  189. //-->
  190. </SCRIPT>
  191. </html>