|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
最后我再次声明,我并没有说不看好java,实际上我对java很乐观的,毕竟她正在不断改进中,我相信她总有一天会和.net并驾齐驱的js|初学|源代码
guestbook.jsp
===========================
<html><head>
<METAcontent="text/html;charset=gb2312"http-equiv=Content-Type>
<title>张家界德律风黄页(网上114)</title></head>
<styletype="text/CSS">
<!--
BODY{FONT-FAMILY:"宋体","ArialNarrow","TimesNewRoman";FONT-SI
ZE:9pt}
.p1{FONT-FAMILY:"宋体","ArialNarrow","TimesNewRoman";FONT-SIZ
E:12pt}
A:link{COLOR:#00793d;TEXT-DECORATION:none}
A:visited{TEXT-DECORATION:none}
A:hover{TEXT-DECORATION:underline}
TD{FONT-FAMILY:"宋体","ArialNarrow","TimesNewRoman";FONT-SIZE
:9pt}
.p2{FONT-FAMILY:"宋体","ArialNarrow","TimesNewRoman";FONT-SIZ
E:9pt;LINE-HEIGHT:150%}
.p3{FONT-FAMILY:"宋体","ArialNarrow","TimesNewRoman";FONT-SIZ
E:9pt;LINE-HEIGHT:120%}
-->
</style>
<body>
<%@pagecontentType="text/html;charset=GB2312"%>
<%@pagelanguage="java"import="java.sql.*"%>
<jsp:useBeanid="testInq"scope="page"class="ymbean.opDb"/>
<%
intpages=1;
intpagesize=10;
intcount=0;
inttotalpages=0;
Stringcountsql="",inqsql="",lwhere="",insertsql="",st="";
Stringlw_title="",lw_author="",pagetitle="",author_http="",author_e
mail="",lw_ico="",
lw_content="",lw_class1="";
Stringauthor_ip="",lw_time="",lw_class2="",lw_type="",zt_time="",zt
_author="";
intanswer_num=0,click_num=0;
intinquire_item=1;
Stringinquire_itemt="",inquire_value="";
Stringlurlt="<ahref=guestbook.jsp?",llink="";
lwhere="wherelw_type=z";//只显现主贴
/*
Enumeratione=request.getParameterNames();
while(e.hasMoreElements()){
Stringname=(String)e.nextElement();
*/
try{
//取显现的页页序数
pages=newInteger(request.getParameter("pages")).intValue();
}catch(Exceptione){}
try{
//取查询参数
inquire_item=newInteger(request.getParameter("range")).intValu
e();
inquire_value=newString(request.getParameter("findstr").getByt
es("ISO8859_1"));
if(inquire_item==0)inquire_itemt="lw_title";
elseif(inquire_item==1)inquire_itemt="lw_content";
elseif(inquire_item==2)inquire_itemt="lw_author";
elseif(inquire_item==3)inquire_itemt="lw_time";
elseif(inquire_item==4)inquire_itemt="lw_title";
lwhere=lwhere+"and"+inquire_itemt+"like%"+inquire_value+"%
";
lurlt=lurlt+"range="+inquire_item+"&findstr="+inquire_value+"&"
;
}catch(Exceptione){}
try{
//获得参数留言内容
lw_class1=newString(request.getParameter("gbname").getBytes("ISO885
9_1"));
lw_title=newString(request.getParameter("lw_title").getBytes("ISO88
59_1"));
lw_author=newString(request.getParameter("lw_author").getBytes("ISO
8859_1"));
pagetitle=newString(request.getParameter("pagetitle").getBytes("ISO
8859_1"));
author_http=newString(request.getParameter("author_http").getBytes(
"ISO8859_1"));
author_email=newString(request.getParameter("author_email").getByte
s("ISO8859_1"));
lw_ico=request.getParameter("gifface");
lw_content=newString(request.getParameter("lw_content").getBytes("I
SO8859_1"));
StringrequestMethod=request.getMethod();
requestMethod=requestMethod.toUpperCase();
if(requestMethod.indexOf("POST")<0)
{out.print("不法操纵!");
return;
}
//构成其他数据项
author_ip=request.getRemoteAddr();
lw_time=testInq.getCurrentDate("yyyyMMddHHmmss");
lw_class2="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="insertintoguestbookvalues("+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{
Stringlmsg=testInq.executeUpdate(insertsql);
if(lmsg.indexOf("executeUpdateok")<0)
out.print("lmsg="+lmsg);
}catch(Exceptione){out.print("毛病:"+e);}
}catch(Exceptione){}
%>
<%
//考证留言输出项正当性的javascript
Stringljs="<SCRIPTlanguage=JavaScript>
"+
"<!--
"+
"functionValidInput()
"+
"{if(document.sign.lw_author.value=="")
"+
"{alert("请填写您的台甫。");
"+
"document.sign.lw_author.focus();
"+
"returnfalse;}
"+
"if(document.sign.lw_title.value=="")
"+
"{alert("请填写留言主题。");
"+
"document.sign.lw_title.focus();
"+
"returnfalse;}
"+
"if(document.sign.author_email.value!="")
"+
"{if((document.sign.author_email.value.indexOf("@")<0)//(document
.sign.author_email.value.indexOf(":")!=-1))
"+
"{alert("您填写的EMail有效,请填写一个无效的Email!");
"+
"document.sign.author_emaill.focus();
"+
"returnfalse;
"+
"}
"+
"}
"+
"returntrue;
"+
"}
"+
"functionValidSearch()
"+
"{if(document.frmsearch.findstr.value=="")
"+
"{alert("不克不及搜刮空串!");
"+
"document.frmsearch.findstr.focus();
"+
"returnfalse;}
"+
"}
"+
"//-->
"+
"</SCRIPT>";
out.print(ljs);
%>
<%
//留言板界面首部
Stringltop="<DIValign=center>
"+
"<CENTER>
"+
"<FORMaction=guestbook.jspmethod=postname=frmsearch>
"+
"<INPUTname=gbnametype=hiddenvalue=cnzjj_gt>
"+
"<TABLEalign=centerborder=0cellSpacing=1width="95%">
"+
"<TBODY>
"+
"<TR>
"+
"<TDbgColor=#336699colSpan=2width="100%">
"+
"<Palign=center><FONTcolor=#ffffffface=楷体_GB2312
"+
"size=5>接待远方的伴侣来张家界旅游参观</FONT></P></TD></TR>
"
+
"<TRbgColor=#6699cc>
"+
"<TDalign=leftnoWrapwidth="50%">主页:<A
"+
"href="http://www.zj.hn.cn"target=_blank><FONT
"+
"color=#ffffff>张家界旅游</FONT></A>办理员:<A
"
+
"href="mailto:dzx@mail.zj.hn.cninfo.net"><FONTcolor=#ffffff>
一平易近</FONT></A>
"+
">><A
"+
"href="http://www.zj.hn.cn"><FONT
"+
"color=#ffffff>办理</FONT></A>>><A
"+
"href="http://www.zj.hn.cn"><FONT
"+
"color=#ffffff>请求</FONT></A></TD>
"+
"<TDalign=rightwidth="50%"><SELECTclass=ourfontname=ranges
ize=1>
"+
"<OPTIONselectedvalue=0>按主题</OPTION><OPTIONvalue=1>按内
容</OPTION>
"+
"<OPTIONvalue=2>按作者</OPTION><OPTIONvalue=3>按日期</OPTI
ON><OPTION
"+
"value=4>按主题&内容</OPTION></SELECT><INPUTname=findst
r><INPUTname=searchonclick="returnValidSearch()"type=submitval
ue="搜索">
"+
"</TD></TR></TBODY></TABLE></FORM>
"+
"<HRalign=centernoShadeSIZE=1width="95%">
"+
"</CENTER></div>";
out.print(ltop);
%>
<%
//显现比来工夫宣布的一页留言
countsql="selectcount(lw_title)fromguestbook"+lwhere;
inqsql="selectlw_title,answer_num,click_num,lw_author,lw_time,expres
sion,"+
"author_email,lw_class1,lw_class2fromguestbook"+lwhere+"o
rderbylw_timedesc";
if(pages>0)
{
try{
try{
ResultSetrcount=testInq.executeQuery(countsql);
if(rcount.next())
{
count=rcount.getInt(1);
}
rcount.close();
}catch(Exceptionel1){out.println("countrecorderror
:"+el1+"<br>");
out.println(countsql);
}
totalpages=(int)(count/pagesize);
if(count>totalpages*pagesize)totalpages++;
st=""+
"<TABLEalign=centerborder=0cellPadding=0cellSpacing=
0width="95%">"+
"<TBODY><TR><TDalign=middlebgColor=#97baddwidth="1
00%"><FONTcolor=#ff0000>"+
"共"+totalpages+"页,"+count+"
条."+"以后页:"+pages+
"</FONT></TD></TR></TBODY></TABLE><BR>";
out.print(st);
//out.print("共"+totalpages+"页,"+
count+"条."+"以后页:"+pages+"<br>");
st="<center>"+
"<TABLEborder=0cellPadding=2cellSpacing=1width="95%">"+
"<TBODY>"+
"<TR>"+
"<TDalign=middlebgColor=#6699ccwidth="55%"><FONT"+
"color=#ffffff>留言主题</FONT></TD>"+
"<TDalign=middlebgColor=#6699ccwidth=50><FONT"+
"color=#ffffff>回应数</FONT></TD>"+
"<TDalign=middlebgColor=#6699ccwidth=40><FONT"+
"color=#ffffff>点击数</FONT></TD>"+
"<TDalign=middlebgColor=#6699ccwidth=100><FONT"+
"color=#ffffff>作者名</FONT></TD>"+
"<TDalign=middlebgColor=#6699ccwidth=140><FONT"+
"color=#ffffff>宣布/回应工夫</FONT></TD></TR>";
out.print(st);
if(count>0)
{
ResultSetrs=testInq.executeQuery(inqsql);
ResultSetMetaDatametaData=rs.getMetaData();
inti;
//跳过pages-1页,使cursor指向pages并筹办显现
for(i=1;i<=(pages-1)*pagesize;i++)rs.next();
//显现第pages页入手下手
Stringlinestr="";
for(i=1;i<=pagesize;i++)
if(rs.next())
{
lw_title=rs.getString("lw_title");
answer_num=rs.getInt("answer_num");
click_num=rs.getInt("click_num");
lw_author=rs.getString("lw_author");
lw_time=rs.getString("lw_time");
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);
lw_ico=rs.getString("expression");
author_email=rs.getString("author_email");
lw_class1=rs.getString("lw_class1");
lw_class2=rs.getString("lw_class2");
llink="reply.jsp?lw_class1="+lw_class1+"&lw_class2="+lw_
class2+"&zt_time="+lw_time+
"&zt_author="+author_email;
linestr="<TRbgColor=#d5e8fd>
"+
"<TDbgColor=#d5e8fd><I
NPUT
"+
"name=giffacetype=radiovalue=2><INPUTname=giffacetype=radiovalue=3
><I
NPUT
"+
"name=giffacetype=radiovalue=4><INPUTname=giffacetype=radiovalue=5
><I
NPUT
"+
"name=giffacetype=radiovalue=6><INPUTname=giffacetype=radiovalue=7
><I
NPUT
"+
"name=giffacetype=radiovalue=8><INPUTname=giffacetype=radiovalue=9
><I
NPUT
"+
"name=giffacetype=radiovalue=10><INPUTname=giffacetype=radiovalue=
11><
INPUT
"+
"name=giffacetype=radiovalue=12>
"+
"<INPUT
"+
"name=giffacetype=radiovalue=13>
"+
"<INPUT
"+
"name=giffacetype=radiovalue=14>
"+
"<INPUT
"+
"name=giffacetype=radiovalue=15>
"+
"<INPUT
"+
"name=giffacetype=radiovalue=16></TD>
"+
"</TR>
"+
"<TR>
"+
"<TDalign=middlecolSpan=2noWrap><INPUTname=cmdGOonclick="re
turnValidInput()"type=submitvalue="提交">
"+
"<INPUTname=cmdPrevonclick="returnValidInput()"type=submitvalu
e="预览">
"+
"<INPUTname=cmdCanceltype=resetvalue="重写"><INPU
Tname=cmdBackonclick=javascript:history.go(-1)type=buttonvalue="返
回">
"+
"</TD></TR></TBODY></TABLE></FORM></CENTER></DIV>";
out.print(lbottom);
%>
</body></html>
还得说上一点,就java本质而言,是面相对象的,但是你有没有发现,java也不全是,比如说基本类型,int,那他就是整型而不是对象,转换类型是还得借助包装类。 |
|