作 者: precom (皮蛋) 2000.12.10
reply.jsp
====================================
<html><head>
<META content="text/html; charset=gb2312 " http-equiv=Content-Type>

<title>张家界电话黄页(网上114)</title></head>
<style type="text/css">
<!--
BODY { FONT-FAMILY: "宋体","Arial Narrow", "Times New Roman"; FONT-SI
ZE: 9pt }
.p1 { FONT-FAMILY: "宋体", "Arial Narrow", "Times New Roman"; FONT-SIZ
E: 12pt }
A:link { COLOR: #00793d; TEXT-DECORATION: none }
A:visited { TEXT-DECORATION: none }
A:hover { TEXT-DECORATION: underline}
TD { FONT-FAMILY: "宋体", "Arial Narrow", "Times New Roman"; FONT-SIZE
: 9pt }
.p2 { FONT-FAMILY: "宋体", "Arial Narrow", "Times New Roman"; FONT-SIZ
E: 9pt; LINE-HEIGHT: 150% }
.p3 { FONT-FAMILY: "宋体", "Arial Narrow", "Times New Roman"; FONT-SIZ
E: 9pt; LINE-HEIGHT: 120% }

-->
</style>


<body>


<%@ page contentType="text/html; charset=GB2312" %>
<%@ page language="java" import="java.sql.*" %>
<jsp:useBean id="testInq" scope="page" class="ymbean.opDb" />
<%
int pages=1;
int pagesize=10;
int count=0;
int totalpages=0;

String countsql="",inqsql="",updatesql="",lwhere="",insertsql="",st=
"";

String lw_title="",lw_author="",pagetitle="",author_http="",author_e
mail="",lw_ico="0",
lw_content="",lw_class1="";
String author_ip="",lw_time="",lw_class2="",lw_type="",zt_time="",zt
_author="";
int answer_num=0,click_num=0;
int inquire_item=1;
String inquire_itemt="",inquire_value="";
String lurlt="<a href=reply.jsp?";

lwhere=" where "; //只显示主贴

/*
Enumeration e = request.getParameterNames();
while (e.hasMoreElements()) {
String name = (String) e.nextElement();
*/
try{
//取显示的页页序数
pages = new Integer(request.getParameter("pages")).intValue();
} catch (Exception e) {}
try{
//取查询参数
lw_class1=new String(request.getParameter("lw_class1").getBytes
("ISO8859_1"));
lw_class2=new String(request.getParameter("lw_class2").getBytes
("ISO8859_1"));
zt_time=new String(request.getParameter("zt_time").getBytes("IS
O8859_1"));
zt_author=new String(request.getParameter("zt_author").getBytes
("ISO8859_1"));

lwhere=" where ( lw_class1='" lw_class1 "' and lw_class2='" lw_
class2
"' and (lw_time='" zt_time "' or zt_time='" zt_time
"') and (author_email='" zt_author "' or zt_author='" zt
_author "') ) ";
lurlt=lurlt "lw_class1=" lw_class1 "&lw_class2=" lw_class2 "&zt
_time=" zt_time
"&zt_author=" zt_author "&";
//out.print(lwhere);
} catch (Exception e) { //out.print("error1: " e "<hr>");
}

try{
//取得参数 留言内容
lw_class1=new String(request.getParameter("lw_class1").getBytes("ISO
8859_1"));
lw_class2=new String(request.getParameter("lw_class2").getBytes("ISO
8859_1"));
lw_title=new String(request.getParameter("lw_title").getBytes("ISO88
59_1"));
lw_author=new String(request.getParameter("lw_author").getBytes("ISO
8859_1"));
pagetitle=new String(request.getParameter("pagetitle").getBytes("ISO
8859_1"));
author_http=new String(request.getParameter("author_http").getBytes(
"ISO8859_1"));
author_email=new String(request.getParameter("author_email").getByte
s("ISO8859_1"));
zt_time=new String(request.getParameter("zt_time").getBytes("ISO8859
_1"));
zt_author=new String(request.getParameter("zt_author").getBytes("ISO
8859_1"));
lw_ico=request.getParameter("gifface");

} catch (Exception e) {}

try{
lw_content=new String(request.getParameter("lw_content").getBytes("I
SO8859_1"));
String requestMethod=request.getMethod();
requestMethod=requestMethod.toUpperCase();
if(requestMethod.indexOf("POST")<0)
{ out.print("非法操作!");
return;
}

//形成其他数据项
author_ip=request.getRemoteAddr() ;
lw_time=testInq.getCurrentDate("yyyyMMddHHmmss");
lw_type="" "c"; //从贴
answer_num=0;
click_num=0;
//================
st="','";
//保证留言所有数据项的长度在正常范围内
if(lw_title.length()>50) lw_title=lw_title.substring(0,50);
if(lw_author.length()>20) lw_author=lw_author.substring(0,20);
if(author_http.length()>40) author_http=author_http.substring(0,40);

if(author_email.length()>50) author_email=author_email.substring(0,4
0);
if(zt_author.length()>50) zt_author=zt_author.substring(0,40);
if(lw_content.length()>4000) lw_content=lw_content.substring(0,4000)


insertsql="insert into guestbook values('" lw_title st lw_author st
author_http st
author_email st lw_ico st lw_time "'," answer_num "," cli
ck_num ",'"
author_ip st lw_class1 st lw_class2 st lw_type st zt_time
st zt_author st
lw_content "')";
//out.print(insertsql);
//插入留言
try{
st=testInq.executeUpdate(insertsql);
if(st.indexOf("executeUpdate ok")<0)
out.print("msg=" st);
else
{
updatesql="update guestbook set answer_num=answer_num 1 " l
where;
//增加回复人数统计
try{
st=testInq.executeUpdate(updatesql);
if(st.indexOf("executeUpdate ok")<0)
out.print("msg=" st);
}catch (Exception e) { }
}
}catch (Exception e) { out.print("留言出错:" e);}
} catch (Exception e) {}
%>

<%
//验证留言输入项合法性的javascript
String ljs=" <SCRIPT language=JavaScript> \n"
" <!-- \n"
" function ValidInput() \n"
" {if(document.sign.lw_author.value==\"\") \n"
" {alert(\"请填写您的大名。\"); \n"
" document.sign.lw_author.focus(); \n"
" return false;} \n"
" if(document.sign.lw_title.value==\"\") \n"
" {alert(\"请填写留言主题。\"); \n"
" document.sign.lw_title.focus(); \n"
" return false;} \n"
" if (document.sign.author_email.value!=\"\") \n"
" { if ((document.sign.author_email.value.indexOf(\"@\")<0)//(document
.sign.author_email.value.indexOf(\":\")!=-1)) \n"
" {alert(\"您填写的EMail无效,请填写一个有效的Email!\"); \n"
" document.sign.author_emaill.focus(); \n"
" return false; \n"
" } \n"
" } \n"
" return true; \n"
" } \n"
" function ValidSearch() \n"
" { if(document.frmsearch.findstr.value==\"\") \n"
" {alert(\"不能搜索空串!\"); \n"
" document.frmsearch.findstr.focus(); \n"
" return false;} \n"
" } \n"
" //--> \n"
" </SCRIPT> ";
out.print(ljs);
%>


<%
//显示最近时间发表的一页留言
countsql="select count(lw_title) from guestbook " lwhere;
inqsql ="select lw_title,lw_author,lw_time,lw_content,author_ip, "
" author_email from guestbook " lwhere " order by lw_time desc
" ;
updatesql="update guestbook set click_num=click_num 1 " lwhere;

//增加浏览人数统计
try{
st=testInq.executeUpdate(updatesql);
if(st.indexOf("executeUpdate ok")<0)
out.print("msg=" st);
}catch (Exception e) { }

//out.print(inqsql);
if(pages>0)
{
try {
try{
ResultSet rcount=testInq.executeQuery(countsql);
if(rcount.next())
{
count = rcount.getInt(1);
}
rcount.close();
} catch (Exception el1) { out.println("count record error
: " el1 "<br>" );
out.println(countsql);
}

totalpages=(int)(count/pagesize);
if(count>totalpages*pagesize) totalpages ;
st=""
" <TABLE align=center border=0 cellPadding=0 cellSpacing=
0 width=\"95%\"> "
" <TBODY> <TR> <TD align=middle bgColor=#97badd width=\"1
00%\"><FONT color=#ff0000>"
" 共 " totalpages " 页," count "
条. " " 当前页: " pages
" </FONT></TD></TR></TBODY></TABLE><BR> ";

out.print(st);

//out.print(" 共 " totalpages " 页,"
count " 条. " " 当前页: " pages "<br>");

st=" <center> "
" <TABLE border=0 cellPadding=2 cellSpacing=1 width=\"95%\"> "
" <TBODY> "
" <TR> "
" <TD align=middle bgColor=#6699cc width=\"55%\"><FONT "
" color=#ffffff>留言主题</FONT></TD> "
" <TD align=middle bgColor=#6699cc width=50><FONT "
" color=#ffffff>回应数</FONT></TD> "
" <TD align=middle bgColor=#6699cc width=40><FONT "
" color=#ffffff>点击数</FONT></TD> "
" <TD align=middle bgColor=#6699cc width=100><FONT "
" color=#ffffff>作者名</FONT></TD> "
" <TD align=middle bgColor=#6699cc width=140><FONT "
" color=#ffffff>发表/回应时间</FONT></TD></TR> ";
//out.print(st);

if(count > 0 )
{
ResultSet rs = testInq.executeQuery(inqsql);
ResultSetMetaData metaData = rs.getMetaData();

int i;
// 跳过pages -1 页,使cursor指向pages并准备显示
for(i=1;i<=(pages - 1)*pagesize;i ) rs.next();
//显示第pages页开始
st= " <CENTER> <TABLE border=0 cellSpacing=1 width=\"95%\"
> <TBODY> ";
out.print(st);
String linestr="";
for(i=1;i<=pagesize;i )
if(rs.next())
{
lw_title=rs.getString("lw_title");
lw_author=rs.getString("lw_author");
lw_time=rs.getString("lw_time");
lw_content=rs.getString("lw_content");
author_ip=rs.getString("author_ip");
author_email=rs.getString("author_email");
st=lw_time.substring(0,4) "-" lw_time.substring(4,6) "-"
lw_time.substring(6,8) ":"
lw_time.substring(8,10) ":" lw_time.substring(10,12)
":" lw_time.substring(12,14);
try{lw_content=testInq.addBr(testInq.removeComment(lw_co
ntent));} catch (Exception e) {}
linestr =""
" <TR bgColor=#bed9fc> "
" <TD align=left width=\"75%\"><FONT "
" color=#0000cd>留言主题:</FONT><STRONG>"
lw_title "</STRONG></TD> "
" <TD align=left width=\"25%\"><FONT color=
#0000cd>留言时间:</FONT>" st "</TD></TR> "
" <TR bgColor=#e7f1fe> "
" <TD colSpan=2 "
" width=\"700\" wrap=yes><BR>" lw_content "
<BR><br></TD></TR> "
" <TR bgColor=#bed9fc> "
" <TD align=right colSpan=2 width=\"100%\">
<FONT "
" color=#0000cd>作者:</FONT>" lw_author "
<FONT "
" color=#0000cd>来源:</FONT>" author_ip "
</TD></TR>";
out.println(linestr);

}
rs.close();
//显示第pages页结束
st= " </TBODY></TABLE></CENTER></DIV><BR> "

" <CENTER><A "
" href=\"guestbook.jsp\"><FONT "
" color=blue face=楷体_GB2312 size=4>返回留言板
首页</FONT></A></CENTER><BR> "
" <HR align=center noShade SIZE=1 width=\"95%\"
> ";

out.print(st);

int iFirst=1,iLast=totalpages,iPre,iNext;
if(pages<=1) iPre=1;
else iPre=pages - 1;

if(pages>=totalpages) iNext=totalpages;
else iNext=pages 1;

int n=(int)(count/pagesize);
if(n*pagesize<count) n ;
if(n>1)
{
//for(i=1;i<=n;i ) out.print("<a href=inquire.jsp?pages=
" i ">" i " </a>");
//out.print("<HR align=center noShade SIZE=1 width=\"95%\
">");
String lt1="返回主页",lt2="第一页",lt3="上一页",lt4="下一
页",lt5="最后一页",lt6="";
lt6="<a href=http://www.zj.hn.cn>" lt1 " </
a>"
lurlt "pages=" iFirst "><FONT color=red>" lt2 "&nbs
p; </a>"
lurlt "pages=" iPre "><FONT color=red>" lt3 "
</a>"
lurlt "pages=" iNext "><FONT color=red>" lt4 "
; </a>"
lurlt "pages=" iLast "><FONT color=red>" lt5 "
; </a>";
st=""
" <TABLE align=center border=0 cellPadding=0 cellSpacing=
0 width=\"95%\"> "
" <TBODY> <TR> <TD align=middle bgColor=#97badd width=\"1
00%\"><FONT color=#ff0000>"
lt6
" </FONT></TD></TR></TBODY></TABLE><BR> ";

out.print(st);

}

}
} catch (Exception e) { out.println("error: " e); }
}


%>


<%
//留言板界面尾部
String lbottom="";
lbottom=lbottom
" <center> \n"
" <FORM action=reply.jsp method=post name=sign> \n"
" <INPUT name=lw_class1 type=hidden value=cnzjj_gt> \n"
" <INPUT name=lw_class2 type=hidden value=" lw_class2 "> \n"

" <INPUT name=pages type=hidden value=1> \n"
" <INPUT name=zt_time type=hidden value=" zt_time "> \n"
" <INPUT name=zt_author type=hidden value=" zt_author "> \n"

" <TABLE bgColor=#d5e8fd border=0 cellSpacing=1 width=\"95%\"> \n"

" <TBODY> \n"
" <TR> \n"
" <TD align=middle bgColor=#e6e6fa colSpan=2 noWrap><STRONG><FONT
color=blue \n"
" face=楷体_GB2312 size=5>发 表 意 见</FONT></STRONG> &nbs
p; [加*的内容必须填写] </TD></TR> \n"
" <TR> \n"
" <TD noWrap width=\"45%\"> \n"
" <DIV align=left> \n"
" <TABLE bgColor=#d5e8fd border=0 cellSpacing=1 width=\"100%\">
\n"
" <TBODY> \n"
" <TR> \n"
" <TD noWrap width=\"100%\">*留言主题:<INPUT maxLength=40 n
ame=lw_title \n"
" size=36></TD></TR> \n"
" <TR> \n"
" <TD noWrap width=\"100%\">*网上大名:<INPUT maxLength=18 n
ame=lw_author \n"
" size=36></TD></TR> \n"
" <TR> \n"
" <TD noWrap width=\"100%\"> 主页标题:<INPUT maxLength
=40 name=pagetitle \n"
" size=36></TD></TR> \n"
" <TR> \n"
" <TD noWrap width=\"100%\"> 主页地址:<INPUT maxLength
=255 name=author_http \n"
" size=36></TD></TR> \n"
" <TR> \n"
" <TD noWrap width=\"100%\">*电子邮件:<INPUT maxLength=40 n
ame=author_email \n"
" size=36></TD></TR></TBODY></TABLE></DIV></TD> \n"
" <TD noWrap vAlign=top width=\"55%\"> \n"
" <DIV align=left> \n"
" <TABLE bgColor=#b6d7fc border=0 cellSpacing=1 width=\"100%\">
\n"
" <TBODY> \n"
" <TR> \n"
" <TD width=\"100%\">请在下面填写你的留言:</TD></TR> \n"

" <TR> \n"
" <TD width=\"100%\"><TEXTAREA cols=50 name=lw_content rows=
7></TEXTAREA></TD></TR></TBODY></TABLE></DIV></TD></TR> \n"
" <TR> \n"
" <TD bgColor=#fbf7ea colSpan=2 noWrap>表情\n"
" <INPUT name=gifface type=radio value=1 checked><IMG \n"
" alt=\"1.gif (152 bytes)\" height=15 src=\"1.gif\" width=15> <I
NPUT \n"
" name=gifface type=radio value=2><IMG alt=\"2.gif (174 bytes)\"
height=15 \n"
" src=\"2.gif\" width=15> <INPUT name=gifface type=radio value=3
><IMG \n"
" alt=\"3.gif (147 bytes)\" height=15 src=\"3.gif\" width=15> <I
NPUT \n"
" name=gifface type=radio value=4><IMG alt=\"4.gif (172 bytes)\"
height=15 \n"
" src=\"4.gif\" width=15> <INPUT name=gifface type=radio value=5
><IMG \n"
" alt=\"5.gif (118 bytes)\" height=15 src=\"5.gif\" width=15> <I
NPUT \n"
" name=gifface type=radio value=6><IMG alt=\"6.gif (180 bytes)\"
height=15 \n"
" src=\"6.gif\" width=15> <INPUT name=gifface type=radio value=7
><IMG \n"
" alt=\"7.gif (180 bytes)\" height=15 src=\"7.gif\" width=15> <I
NPUT \n"
" name=gifface type=radio value=8><IMG alt=\"8.gif (96 bytes)\"
height=15 \n"
" src=\"8.gif\" width=15> <INPUT name=gifface type=radio value=9
><IMG \n"
" alt=\"9.gif (162 bytes)\" height=15 src=\"9.gif\" width=15> <I
NPUT \n"
" name=gifface type=radio value=10><IMG alt=\"10.gif (113 bytes)
\" height=15 \n"
" src=\"10.gif\" width=15> <INPUT name=gifface type=radio value=
11><IMG \n"
" alt=\"11.gif (93 bytes)\" height=15 src=\"11.gif\" width=15> <
INPUT \n"
" name=gifface type=radio value=12> <IMG alt=\"12.gif (149 bytes
)\" height=14 \n"
" src=\"12.gif\" width=15> \n"
" <INPUT \n"
" name=gifface type=radio value=13> <IMG alt=\"13.gif (149 bytes
)\" height=14 \n"
" src=\"13.gif\" width=15> \n"
" <INPUT \n"
" name=gifface type=radio value=14> <IMG alt=\"14.gif (149 bytes
)\" height=14 \n"
" src=\"14.gif\" width=15> \n"
" <INPUT \n"
" name=gifface type=radio value=15> <IMG alt=\"15.gif (149 bytes
)\" height=14 \n"
" src=\"15.gif\" width=15> \n"
" <INPUT \n"
" name=gifface type=radio value=16> <IMG alt=\"16.gif (149 bytes
)\" height=14 \n"
" src=\"16.gif\" width=15> </TD> \n"
" </TR> \n"
" <TR> \n"
" <TD align=middle colSpan=2 noWrap><INPUT name=cmdGO onclick=\"re
turn ValidInput()\" type=submit value=\"提 交\"> \n"

" <INPUT name=cmdPrev onclick=\"return ValidInput()\" type=submit valu
e=\"预 览\"> \n"
" <INPUT name=cmdCancel type=reset value=\"重 写\"> <INPU
T name=cmdBack onclick=javascript:history.go(-1) type=button value=\"返
回\"> \n"
" </TD></TR></TBODY></TABLE></FORM></CENTER></DIV> ";
out.print(lbottom);

%>

</body></html>

作 者: precom (皮蛋) 2000.12.10

jsp留言板源代码三: 给jsp初学者.的更多相关文章

  1. html5 拖拽及用 js 实现拖拽功能的示例代码

    这篇文章主要介绍了html5 拖拽及用 js 实现拖拽,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下

  2. amaze ui 的使用详细教程

    这篇文章主要介绍了amaze ui 的使用详细教程,本文通过多种方法给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下

  3. swift皮筋弹动发射飞机ios源码

    这是一个款采用swift实现的皮筋弹动发射飞机游戏源码,游戏源码比较详细,大家可以研究学习一下吧。

  4. 10.5 Swift类方法

    /**类型方法通过类名称来调用的方法,就像类型属性一样。

  5. Swift与Js通过WebView交互

    开发环境:Swfit2.3XCode8.2基础概念jscontext,jscontext是代表JS的执行环境,通过-evaluateScript:方法就可以执行一JS代码JSValue,JSValue封装了JS与ObjC中的对应的类型,以及调用JS的API等JSExport,JSExport是一个协议,遵守此协议,就可以定义我们自己的协议,在协议中声明的API都会在JS中暴露出来,才能调用Swif

  6. JSCore swift

    如果双方相互引用,会造成循环引用,而导致内存泄露。以上是Jscore的基本使用,比较简单

  7. Swift WKWebView的js调用swift

    最近项目需求,需要用到JavaScriptCore和WebKit,但是网上的资源有限,而且比较杂,都是一个博客复制另外一个博客,都没有去实际敲代码验证,下面给大家分享一下我的学习过程。

  8. Swift WKWebView的swift调用js

    不多说,直接上代码:在html里面要添加的的代码,显示swift传过去的参数:这样就实现了swift给js传参数和调用!

  9. 在 Swift 專案中使用 Javascript:編寫一個將 Markdown 轉為 HTML 的編輯器

    你有強烈的好奇心,希望在你的iOS專案中使用JavaScript。jscontext中的所有值都是JSValue對象,JSValue類用於表示任意類型的JavaScript值。因此,我們既需要寫Swift代碼也要寫JavaScript代碼。此外,我們還會在JavaScript中按照這個類的定義來創建一個對象并對其屬性進行賦值。從Swift中呼叫JavaScript就如介紹中所言,JavaScriptCore中最主要的角色就是jscontext類。一個jscontext對象是位於JavaScript環境和本

  10. swift - WKWebView JS 交互

    本文介绍WKWebView怎么与js交互,至于怎么用WKWebView这里就不介绍了HTML代码APP调JS代码结果JS给APP传参数首先注册你需要监听的js方法名2.继承WKScriptMessageHandler并重写userContentController方法,在该方法里接收JS传来的参数3.结果

随机推荐

  1. 基于EJB技术的商务预订系统的开发

    用EJB结构开发的应用程序是可伸缩的、事务型的、多用户安全的。总的来说,EJB是一个组件事务监控的标准服务器端的组件模型。基于EJB技术的系统结构模型EJB结构是一个服务端组件结构,是一个层次性结构,其结构模型如图1所示。图2:商务预订系统的构架EntityBean是为了现实世界的对象建造的模型,这些对象通常是数据库的一些持久记录。

  2. Java利用POI实现导入导出Excel表格

    这篇文章主要为大家详细介绍了Java利用POI实现导入导出Excel表格,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下

  3. Mybatis分页插件PageHelper手写实现示例

    这篇文章主要为大家介绍了Mybatis分页插件PageHelper手写实现示例,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪

  4. (jsp/html)网页上嵌入播放器(常用播放器代码整理)

    网页上嵌入播放器,只要在HTML上添加以上代码就OK了,下面整理了一些常用的播放器代码,总有一款适合你,感兴趣的朋友可以参考下哈,希望对你有所帮助

  5. Java 阻塞队列BlockingQueue详解

    本文详细介绍了BlockingQueue家庭中的所有成员,包括他们各自的功能以及常见使用场景,通过实例代码介绍了Java 阻塞队列BlockingQueue的相关知识,需要的朋友可以参考下

  6. Java异常Exception详细讲解

    异常就是不正常,比如当我们身体出现了异常我们会根据身体情况选择喝开水、吃药、看病、等 异常处理方法。 java异常处理机制是我们java语言使用异常处理机制为程序提供了错误处理的能力,程序出现的错误,程序可以安全的退出,以保证程序正常的运行等

  7. Java Bean 作用域及它的几种类型介绍

    这篇文章主要介绍了Java Bean作用域及它的几种类型介绍,Spring框架作为一个管理Bean的IoC容器,那么Bean自然是Spring中的重要资源了,那Bean的作用域又是什么,接下来我们一起进入文章详细学习吧

  8. 面试突击之跨域问题的解决方案详解

    跨域问题本质是浏览器的一种保护机制,它的初衷是为了保证用户的安全,防止恶意网站窃取数据。那怎么解决这个问题呢?接下来我们一起来看

  9. Mybatis-Plus接口BaseMapper与Services使用详解

    这篇文章主要为大家介绍了Mybatis-Plus接口BaseMapper与Services使用详解,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪

  10. mybatis-plus雪花算法增强idworker的实现

    今天聊聊在mybatis-plus中引入分布式ID生成框架idworker,进一步增强实现生成分布式唯一ID,具有一定的参考价值,感兴趣的小伙伴们可以参考一下

返回
顶部