jsp留言板源代码(2) guestbook.jsp =
jsp留言板
源代码(2)
guestbook.jsp
=
htmlhead
META content="text/html; charset=gb2312 " http-equiv=Content-Type
title张家界电话黄页/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="",lwhere="",insert
sql="",st="";
String lw_title="",lw_author="",pagetitle="",author_http="",author_e
mail="",lw_ico="",
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=guestbook.jsp?",llink="";
lwhere=" where lw_type=z "; 只显示主贴
/*
Enumeration e = request.getParameterNames;
while ) {
String name =e.nextElement;
*/
try{
取显示的页页序数
pages = new Integer).intValue;
} catch{}
try{
取
查询参数
inquire_item=new Integer).intValu
e;
inquire_value=new String.getByt
es);
if inquire_itemt="lw_title";
else if inquire_itemt="lw_content";
else if inquire_itemt="lw_author";
else if inquire_itemt="lw_time";
else if inquire_itemt="lw_title";
lwhere=lwhere+" and "+inquire_itemt+" like %"+inquire_value+"%
";
lurlt=lurlt+"range="+inquire_item+"&;findstr="+inquire_value+"&;"
;
} catch{}
try{
取得参数 留言内容
lw_class1=new String.getBytes);
lw_title=new String.getBytes);
lw_author=new String.getBytes);
pagetitle=new String.getBytes);
author_http=new String.getBytes);
author_email=new String.getByte
s);
lw_ico=request.getParameter;
lw_content=new String.getBytes);
String requestMethod=request.getMethod;
requestMethod=requestMethod.toUpperCase;
if0)
{ out.print;
return;
}
形成其他项
author_ip=request.getRemoteAddr ;
lw_time=testInq.getCurrentDate;
lw_class2="2";
lw_type=""+"z"; 主贴
zt_time=lw_time;
zt_author=lw_author;
answer_num=0;
click_num=0;
st=",";
保证留言所有项的长度在正常
范围内
if50) lw_title=lw_title.substring;
if20) lw_author=lw_author.substring;
if40) author_http=author_http.substring;
if50) author_email=author_email.substring;
if4000) lw_content=lw_content.substring
;
insertsql="insert into guestbook values";
out.print;
插入留言
try{
String lmsg=testInq.executeUpdate;
if0)
out.print;
}catch{ out.print;}
} catch{}
%
%
验证留言输入项合法性的javascript
String ljs=" SCRIPT language=
JavaScript "+
" "+
" function ValidInput "+
" {if "+
" {alert; "+
" document.sign.lw_author.focus; "+
" return false;} "+
" if "+
" {alert; "+
" docu