guestbook.jsp
===========================
<meta content=”text/html; charset=gb2312 ” http-equiv=Content-Type>
<style type=”text/css”>
<!—ecms -ecms
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.*” %>
<%
int pages=1;
int pagesize=10;
else if(inquire_item==4) inquire_itemt=”lw_title”;
lwhere=lwhere+” and “+inquire_itemt+” like '%”+inquire_value+”%
'”;
lurlt=lurlt+”range=”+inquire_item+”&findstr=”+inquire_value+”&”
;
} catch (Exception e) {}
try{
//取得参数 留言内容
lw_ String(request.getParameter(“gbname”).getBytes(“ISO885
9_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”));
lw_ico=request.getParameter(“gifface”);
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_”2″;
lw_type=””+”z”; //主贴
zt_time=lw_time;
zt_author=lw_author;
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(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{
String lmsg=testInq.executeUpdate(insertsql);
if(lmsg.indexOf(“executeUpdate ok”)<0)
out.print(“lmsg=”+lmsg);
}catch (Exception e) { out.print(“错误:”+e);}
} catch (Exception e) {}
%>
<%
//验证留言输入项合法性的javascript
String ljs=” <script language=JavaScript> \n”+
” <!—ecms -ecms \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);
%>
<%
//留言板界面首部
String ltop=”
” \n”+
” \n”+
” \n”+
”
\n”+ ” <FONT color=#ffffff face=楷体_GB2312 \n"+ | |
主页: ” href=\”http://www.zj.hn.cn\” target=_blank><FONT \n"+ ” color=#ffffff>张家界旅游 管理员: + ” href=\”mailto:[email protected]\”> 一民 \n”+ ” >> ” href=\”http://www.zj.hn.cn \”><FONT \n"+ ” color=#ffffff>管理 >> ” href=\” http://www.zj.hn.cn \”><FONT \n"+ ” color=#ffffff>申请 | \n”+ <SELECT s ize=1> \n”+ ” 按主题 按内 容 \n”+ ” 按作者 按日期</OPTI ON> <OPTION \n"+ ” value=4>按主题&内容 <INPUT name=findst r> <INPUT name=search onclick=\"return ValidSearch()\" type=submit val ue=\”搜 索\”> \n”+ ” |
”
\n”+
”
“;
out.print(ltop);
%>
<%
//显示最近时间发表的一页留言
countsql=”select count(lw_title) from guestbook “+lwhere;
inqsql =”select lw_title,answer_num,click_num,lw_author,lw_time,expres
sion,”+
” author_email,lw_class1,lw_class2 from guestbook “+lwhere+” o
rder by lw_time desc” ;
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+”
” );
out.println(countsql);
}
totalpages=(int)(count/pagesize);
if(count>totalpages*pagesize) totalpages++;
st=””+
” <TABLE align=center border=0 cellPadding=0 cellSpacing=
0 width=\”95%\”> “+
”
00%\”>“+
” 共 “+totalpages+” 页,”+count+”
条. “+” 当前页: “+pages+
”
“;
out.print(st);
//out.print(” 共 “+totalpages+” 页,”+
count+” 条. “+” 当前页: “+pages+”
“);
st=” “+
”
<FONT "+ ” color=#ffffff>留言主题 | “+ <FONT "+ ” color=#ffffff>回应数 | “+ <FONT "+ ” color=#ffffff>点击数 | “+ <FONT "+ ” color=#ffffff>作者名 | “+ <FONT "+ ” color=#ffffff>发表/回应时间 |
“> ” href=\””+llink+” \”>”+lw_title+” | “+[“+answer_num+”] | “+“+click_num+” | “+il+”\”>”+lw_author+” | “+“+st+” |
“;
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”+i+” “);
//out.print(“<HR align=center noShade SIZE=1 width=\"95%\
“>”);
String lt1=”返回主页”,lt2=”第一页”,lt3=”上一页”,lt4=”下一
页”,lt5=”最后一页”,lt6=””;
lt6=””+ lt1 + ” </
a>”+
lurlt + “pages=”+iFirst+”>“+lt2+”&nbs
p; “+
lurlt + “pages=”+iPre+”>“+lt3+”
” +
lurlt + “pages=”+iNext+”>“+lt4+”
; ” +
lurlt + “pages=”+iLast+”>“+lt5+”
; “;
st=””+
” <TABLE align=center border=0 cellPadding=0 cellSpacing=
0 width=\”95%\”> “+
” <TD align=middle bgColor=#97badd width=\"1
00%\”>“+
lt6+
”
“;
out.print(st);
}
}
} catch (Exception e) { out.println(“error: “+e); }
}
%>
<%
//留言板界面尾部
String lbottom=””;
lbottom=lbottom+
” \n”+
” \n”+
” \n”+
” \n”+
”
<FONT color=blue \n”+ ” face=楷体_GB2312 size=5>发 表 意 见 &nbs p; [加*的内容必须填写] | ||||||||
\n”+ ” \n”+ ”
| \n”+ \n”+ ” \n”+ ”
| |||||||
表情\n”+ ” ” alt=http://www.itfat.com/picnet/200411/0511722482857472.gif (152 bytes)\” height=15 alt=jsp留言板源代码二: 给jsp初学者 src=http://www.itfat.com/picnet/200411/0511722482857472.gif\” width=15> <I NPUT \n”+ ” name=gifface type=radio value=2> height=15 \n”+ ” alt=jsp留言板源代码二: 给jsp初学者 src=http://www.itfat.com/picnet/200411/051172248288159.gif\” width=15> <INPUT name=gifface type=radio value=3 > ” alt=http://www.itfat.com/picnet/200411/0511722482942927.gif (147 bytes)\” height=15 alt=jsp留言板源本文来源gao@daima#com搞(%代@#码网@代码二: 给jsp初学者 src=http://www.itfat.com/picnet/200411/0511722482942927.gif\” width=15> <I NPUT \n”+ ” name=gifface type=radio value=4> height=15 \n”+ ” alt=jsp留言板源代码二: 给jsp初学者 src=http://www.itfat.com/picnet/200411/0511722482989922.gif\” width=15> <INPUT name=gifface type=radio value=5 > ” alt=http://www.itfat.com/picnet/200411/0511722483080347.gif (118 bytes)\” height=15 alt=jsp留言板源代码二: 给jsp初学者 src=http://www.itfat.com/picnet/200411/0511722483080347.gif\” width=15> <I NPUT \n”+ ” name=gifface type=radio value=6> height=15 \n”+ ” alt=jsp留言板源代码二: 给jsp初学者 src=http://www.itfat.com/picnet/200411/051172248309558.gif\” width=15> <INPUT name=gifface type=radio value=7 > ” alt=http://www.itfat.com/picnet/200411/0511722483175965.gif (180 bytes)\” height=15 alt=jsp留言板源代码二: 给jsp初学者 src=http://www.itfat.com/picnet/200411/0511722483175965.gif\” width=15> <I NPUT \n”+ ” name=gifface type=radio value=8> height=15 \n”+ ” alt=jsp留言板源代码二: 给jsp初学者 src=http://www.itfat.com/picnet/200411/051172248317717.gif\” width=15> <INPUT name=gifface type=radio value=9 > ” alt=http://www.itfat.com/picnet/200411/051172248324800.gif (162 bytes)\” height=15 alt=jsp留言板源代码二: 给jsp初学者 src=http://www.itfat.com/picnet/200411/051172248324800.gif\” width=15> <I NPUT \n”+ ” name=gifface type=radio value=10> \” height=15 \n”+ ” alt=jsp留言板源代码二: 给jsp初学者 src=http://www.itfat.com/picnet/200411/0511722483239091.gif\” width=15> <INPUT name=gifface type=radio value= 11> ” alt=http://www.itfat.com/picnet/200411/0511722483384022.gif (93 bytes)\” height=15 alt=jsp留言板源代码二: 给jsp初学者 src=http://www.itfat.com/picnet/200411/0511722483384022.gif\” width=15> < INPUT \n”+ ” name=gifface type=radio value=12> )\” height=14 \n”+ ” alt=jsp留言板源代码二: 给jsp初学者 src=http://www.itfat.com/picnet/200411/0511722483394297.gif\” width=15> \n”+ ” <INPUT \n"+ ” name=gifface type=radio value=13> )\” height=14 \n”+ ” alt=jsp留言板源代码二: 给jsp初学者 src=http://www.itfat.com/picnet/200411/0511722483448001.gif\” width=15> \n”+ ” <INPUT \n"+ ” name=gifface type=radio value=14> )\” height=14 \n”+ ” alt=jsp留言板源代码二: 给jsp初学者 src=http://www.itfat.com/picnet/200411/0511722483460816.gif\” width=15> \n”+ ” <INPUT \n"+ ” name=gifface type=radio value=15> )\” height=14 \n”+ ” alt=jsp留言板源代码二: 给jsp初学者 src=http://www.itfat.com/picnet/200411/051172248354598.gif\” width=15> \n”+ ” <INPUT \n"+ ” name=gifface type=radio value=16> )\” height=14 \n”+ ” alt=jsp留言板源代码二: 给jsp初学者 src=http://www.itfat.com/picnet/200411/0511722483599627.gif\” width=15> | \n”+ ||||||||
<INPUT name=cmdGO onclick=\"re turn ValidInput()\” type=submit value=\”提 交\”> \n”+ ” <INPUT name=cmdPrev onclick=\"return ValidInput()\" type=submit valu |