jsp留言板实例源代码

 
oracle数据表创建.

create table guestbook (
lw_title varchar2(100) not null, --留言主题
lw_author varchar2(20) not null, --网上大名 pk
author_http varchar2(40) , --主页地址
author_email varchar2(40) not null,--电子信箱 pk
expression varchar2(2) not null,--表情
lw_time varchar2(14) not null,--发表回应时间
answer_num number(3) not null,--回应数
click_num number(4) not null,--点击数
author_ip varchar2(16) ,--来源ip
lw_class1 varchar2(10) not null,--留言板大类 pk
lw_class2 varchar2(20) not null,--论坛栏目 pk
lw_type varchar2(1) not null,--留言类别,即是否为主贴

zt_time varchar2(14) ,--主贴时间
zt_author varchar2(40) ,--主贴email
lw_content varchar2(4000) ,--内容
constraint pk_guestbook primary key(lw_class1,lw_class2,lw
_time,lw_author)
) storage (initial 5M next 5M pctincrease 1); 
guestbook.jsp
===========================



张家界电话黄页(网上114)






<%@ page contentType="text/html; charset=GB2312" %>
<%@ page language="java" import="java.sql.*" %>

<%
int pages=1;
int pagesize=10;
int count=0;
int totalpages=0;

String countsql="",inqsql="",lwhere="",insertsql="",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="
lwhere=" where lw_type=z "; //只显示主贴

/*
Enumeration e = request.getParameterNames();
while (e.hasMoreElements()) {
String name = (String) e.nextElement();
*/
try{
//取显示的页页序数
pages = new Integer(request.getParameter("pages")).intValue();
} catch (Exception e) {}
try{
//取查询参数
inquire_item=new Integer(request.getParameter("range")).intValu
e();
inquire_value=new String(request.getParameter("findstr").getByt
es("ISO8859_1"));
if(inquire_item==0) inquire_itemt="lw_title";
else if(inquire_item==1) inquire_itemt="lw_content";
else if(inquire_item==2) inquire_itemt="lw_author";
else if(inquire_item==3) inquire_itemt="lw_time";
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_class1=new 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_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="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=" ";
out.print(ljs);
%>

<%
//留言板界面首部
String ltop="

"+
"

"+
"

"+
"
"+
"
"+
"
"+
"
"+
"
"
+
"
"+
"
"+
"

"+
"

"+
" size=5>欢迎远方的朋友来张家界旅游观光

主页: "+
" href="http://www.zj.hn.cn" target=_blank>"+
" color=#ffffff>张家界旅游
管理员: "
+
r> ue="搜 索//">
"+
"

"+
"

"+
"
";
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=""+
" 0 width="95%"> "+
"
"+
" 共 "+totalpages+" 页,"+count+"
条. "+" 当前页: "+pages+
"

";

out.print(st);

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

st="
"+
" "+
" "+
" "+
" "+
" "+
" "+
" "+
" ";
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页开始
String linestr="";
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="
" +
" "+
" "+
" "+
" "+
" ";

out.println(linestr);

}
rs.close();
//显示第pages页结束
st="
" color=#ffffff>留言主题" color=#ffffff>回应数" color=#ffffff>点击数" color=#ffffff>作者名" 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*pagesizeif(n>1)
{
//for(i=1;i<=n;i++) out.print("
"+i+">"+i+" ");
//out.print("
");
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=""+
" 0 width="95%"> "+
"
"+
lt6+
"

";

out.print(st);

}

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


%>


<%
//留言板界面尾部
String lbottom="";
lbottom=lbottom+
"
"+
"

"+
"
"+
"
"+
"
"+

"
"+
"
"+
"
"+
"
"+
"
"+
"
"+
"
"+
"
"+
"
"+
"
"+
"
color=blue
"+
" face=楷体_GB2312 size=5>发 表 意 见
&nbs
p; [加*的内容必须填写]

"+
"

"+
"

"+
"
"+
"
"+
"
"+
"
"+
"
"+
"
"+
"
"+
"
"+
"
"+
"
"+
"
*留言主题:ame=lw_title
"+
" size=36>
*网上大名:ame=lw_author
"+
" size=36>
主页标题:=40 name=pagetitle
"+
" size=36>
主页地址:=255 name=author_http
"+
" size=36>
*电子邮件:ame=author_email
"+
" size=36>

"+
"

"+
"

"+
"
"+
"
"+
"
"+
"

"+
"
请在下面填写你的留言:
表情/
"+
" "+
" alt=/upimg/allimg/071108/1341521.jpg (152 bytes)" height=15 src=/upimg/allimg/071108/1341521.jpg" width=15> NPUT
"+
" name=gifface type=radio value=2>/upimg/allimg/071108/1341522.jpgheight=15
"+
" src=/upimg/allimg/071108/1341522.jpg" width=15> >"+
" alt=/upimg/allimg/071108/1341523.jpg (147 bytes)" height=15 src=/upimg/allimg/071108/1341523.jpg" width=15> NPUT
"+
" name=gifface type=radio value=4>/upimg/allimg/071108/1341524.jpgheight=15
"+
" src=/upimg/allimg/071108/1341524.jpg" width=15> >"+
" alt=/upimg/allimg/071108/1341525.jpg (118 bytes)" height=15 src=/upimg/allimg/071108/1341525.jpg" width=15> NPUT
"+
" name=gifface type=radio value=6>/upimg/allimg/071108/1341526.jpgheight=15
"+
" src=/upimg/allimg/071108/1341526.jpg" width=15> >"+
" alt=/upimg/allimg/071108/1341527.jpg (180 bytes)" height=15 src=/upimg/allimg/071108/1341527.jpg" width=15> NPUT
"+
" name=gifface type=radio value=8>/upimg/allimg/071108/1341528.jpgheight=15
"+
" src=/upimg/allimg/071108/1341528.jpg" width=15> >"+
" alt=/upimg/allimg/071108/1341529.jpg (162 bytes)" height=15 src=/upimg/allimg/071108/1341529.jpg" width=15> NPUT
"+
" name=gifface type=radio value=10>/upimg/allimg/071108/13415210.jpg" height=15
"+
" src=/upimg/allimg/071108/13415210.jpg" width=15> 11>"+
" alt=/upimg/allimg/071108/13415211.jpg (93 bytes)" height=15 src=/upimg/allimg/071108/13415211.jpg" width=15> <
INPUT
"+
" name=gifface type=radio value=12> /upimg/allimg/071108/13415212.jpg)" height=14
"+
" src=/upimg/allimg/071108/13415212.jpg" width=15>
"+
" "+
" name=gifface type=radio value=13> /upimg/allimg/071108/13415213.jpg)" height=14
"+
" src=/upimg/allimg/071108/13415213.jpg" width=15>
"+
" "+
" name=gifface type=radio value=14> /upimg/allimg/071108/13415214.jpg)" height=14
"+
" src=/upimg/allimg/071108/13415214.jpg" width=15>
"+
" "+
" name=gifface type=radio value=15> /upimg/allimg/071108/13415215.jpg)" height=14
"+
" src=/upimg/allimg/071108/13415215.jpg" width=15>
"+
" "+
" name=gifface type=radio value=16> /upimg/allimg/071108/13415216.jpg)" height=14
"+
" src=/upimg/allimg/071108/13415216.jpg" width=15>

"+

" e="预 览">
"+
" T name=cmdBack οnclick=javascript:history.go(-1) type=button value="返
回">
"+
"
";
out.print(lbottom);

%>


reply.jsp
====================================



张家界电话黄页(网上114)






<%@ page contentType="text/html; charset=GB2312" %>
<%@ page language="java" import="java.sql.*" %>

<%
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="
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+"
");
}

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=" ";
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+"
" );
out.println(countsql);
}

totalpages=(int)(count/pagesize);
if(count>totalpages*pagesize) totalpages++;
st=""+
" 0 width="95%"> "+
"
"+
" 共 "+totalpages+" 页,"+count+"
条. "+" 当前页: "+pages+
"

";

out.print(st);

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

st="
"+
" "+
" "+
" "+
" "+
" "+
" "+
" "+
" ";
//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= "
" color=#ffffff>留言主题" color=#ffffff>回应数" color=#ffffff>点击数" color=#ffffff>作者名" color=#ffffff>发表/回应时间
> ";
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 =""+
" "+
" "+
" "+
" "+
" "+
" "+
" ";
out.println(linestr);

}
rs.close();
//显示第pages页结束
st= "
" color=#0000cd>留言主题:"
+lw_title+"
#0000cd>留言时间:"+st+"
" width="700" wrap=yes>
"+lw_content+"



" color=#0000cd>作者:"+lw_author+"
" color=#0000cd>来源:"+author_ip+"

"+

"
" href="guestbook.jsp">" color=blue face=楷体_GB2312 size=4>返回留言板
首页

"+
"
> ";

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*pagesizeif(n>1)
{
//for(i=1;i<=n;i++) out.print(""+i+">"+i+" ");
//out.print("
");
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=""+
" 0 width="95%"> "+
"
"+
lt6+
"

";

out.print(st);

}

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


%>


<%
//留言板界面尾部
String lbottom="";
lbottom=lbottom+
"

"+
"

"+
"
"+
"
"
+
"
"+
"
"+
"
"
+
"
"+

"
"+
"
"+
"
"+
"
"+
"
"+
"
"+
"
"+
"
"+
"
"+
"
"+
"
color=blue
"+
" face=楷体_GB2312 size=5>发 表 意 见
&nbs
p; [加*的内容必须填写]

"+
"

"+
"

"+
"
"+
"
"+
"
"+
"
"+
"
"+
"
"+
"

"+
"
"+
"
"+
"
"+
"
*留言主题:ame=lw_title
"+
" size=36>
*网上大名:ame=lw_author
"+
" size=36>
主页标题:=40 name=pagetitle
"+
" size=36>
主页地址:=255 name=author_http
"+
" size=36>
*电子邮件:ame=author_email
"+
" size=36>

"+
"

"+
"

"+
"
"+
"
"+
"
"+

"
"+
"
请在下面填写你的留言:
表情/
"+
" "+
" alt=/upimg/allimg/071108/1341521.jpg (152 bytes)" height=15 src=/upimg/allimg/071108/1341521.jpg" width=15> NPUT
"+
" name=gifface type=radio value=2>/upimg/allimg/071108/1341522.jpgheight=15
"+
" src=/upimg/allimg/071108/1341522.jpg" width=15> >"+
" alt=/upimg/allimg/071108/1341523.jpg (147 bytes)" height=15 src=/upimg/allimg/071108/1341523.jpg" width=15> NPUT
"+
" name=gifface type=radio value=4>/upimg/allimg/071108/1341524.jpgheight=15
"+
" src=/upimg/allimg/071108/1341524.jpg" width=15> >"+
" alt=/upimg/allimg/071108/1341525.jpg (118 bytes)" height=15 src=/upimg/allimg/071108/1341525.jpg" width=15> NPUT
"+
" name=gifface type=radio value=6>/upimg/allimg/071108/1341526.jpgheight=15
"+
" src=/upimg/allimg/071108/1341526.jpg" width=15> >"+
" alt=/upimg/allimg/071108/1341527.jpg (180 bytes)" height=15 src=/upimg/allimg/071108/1341527.jpg" width=15> NPUT
"+
" name=gifface type=radio value=8>/upimg/allimg/071108/1341528.jpgheight=15
"+
" src=/upimg/allimg/071108/1341528.jpg" width=15> >"+
" alt=/upimg/allimg/071108/1341529.jpg (162 bytes)" height=15 src=/upimg/allimg/071108/1341529.jpg" width=15> NPUT
"+
" name=gifface type=radio value=10>/upimg/allimg/071108/13415210.jpg" height=15
"+
" src=/upimg/allimg/071108/13415210.jpg" width=15> 11>"+
" alt=/upimg/allimg/071108/13415211.jpg (93 bytes)" height=15 src=/upimg/allimg/071108/13415211.jpg" width=15> <
INPUT
"+
" name=gifface type=radio value=12> /upimg/allimg/071108/13415212.jpg)" height=14
"+
" src=/upimg/allimg/071108/13415212.jpg" width=15>
"+
" "+
" name=gifface type=radio value=13> /upimg/allimg/071108/13415213.jpg)" height=14
"+
" src=/upimg/allimg/071108/13415213.jpg" width=15>
"+
" "+
" name=gifface type=radio value=14> /upimg/allimg/071108/13415214.jpg)" height=14
"+
" src=/upimg/allimg/071108/13415214.jpg" width=15>
"+
" "+
" name=gifface type=radio value=15> /upimg/allimg/071108/13415215.jpg)" height=14
"+
" src=/upimg/allimg/071108/13415215.jpg" width=15>
"+
" "+
" name=gifface type=radio value=16> /upimg/allimg/071108/13415216.jpg)" height=14
"+
" src=/upimg/allimg/071108/13415216.jpg" width=15>

"+

" e="预 览">
"+
" T name=cmdBack οnclick=javascript:history.go(-1) type=button value="返
回">
"+
"
";
out.print(lbottom);

%>


其中的opDb.java
============================================
package ymbean;

import java.sql.*;
import java.util.*;
import java.text.*;
import com.chinazjj.sql.dsql;
import com.chinazjj.util.dutil;

//其他的包dsql,dutil中的内容我就不再贴了,在本文件中用到的两个函数都很简


public class opDb {

private String inquire_value="",inquire_item="",disptype="",inqtyp

e="";
private String inquire_num="",inquire_addr="",inquire_name="";
private dutil ldutil=new dutil();
public opDb() {

}

public void setinquire_item(String name) { inquire_item= name

;}
public void setinquire_value( String name ) { inquire_value = ldut

il.chineseToUnicode(name);}
public void setdisptype(String name) { disptype=name;}
public void setinqtype(String name) { inqtype=name;}

public void setinquire_num( String name ) { inquire_num = ldutil.c

hineseToUnicode(name);}
public void setinquire_addr( String name ) { inquire_addr = ldutil

.chineseToUnicode(name);}
public void setinquire_name( String name ) { inquire_name = ldutil

.chineseToUnicode(name);}

public String getinquire_dndata()
{
return "";
}

public ResultSet executeQuery(String sql)
{
ResultSet rs = null;
Statement lstmt = null;
try {
lstmt = connectdb();
rs = lstmt.executeQuery(sql);
System.out.println("executeQuery: "+sql);
} catch(SQLException ex) { System.err.println("executeQuery: " +

ex.getMessage());}
return rs;
}

public Statement getStmt()
{
Statement lstmt = null;
lstmt = connectdb();
return lstmt;
}

public String executeUpdate(String sql)
{
ResultSet rs = null;
Statement lstmt = null;
try {
lstmt = connectdb();
lstmt.executeUpdate(sql);
System.out.println("executeUpdate: "+sql);
lstmt.executeUpdate("commit");
}
catch(SQLException ex) { System.err.println("executeQuery: " + e

x.getMessage());
return(ex.getMessage());
}
return("executeUpdate ok");
}

public Statement connectdb()
{

Statement lstmt=null;
Connection conn=null;

final String connect_string="jdbc:oracle:thin:scott/[email protected].

0.1:1521:clubdb";
final String driver_string="oracle.jdbc.driver.OracleDriver";
dsql mysql=new dsql();
lstmt=mysql.dconnectdb(driver_string,connect_string);
return lstmt;
}

public Statement connectdb(String connect_string)
{
Statement lstmt=null;
Connection conn=null;

final String driver_string="oracle.jdbc.driver.OracleDriver";
dsql mysql=new dsql();
lstmt=mysql.dconnectdb(driver_string,connect_string);
return lstmt;
}


//=========other function ===================================

public String getCurrentDate(String ldateform)
{
return(new SimpleDateFormat(ldateform).format(new java.util.Date(

)));
}

//========"/n" to "
" =====================================
//去掉奇怪的:
public String removeComment(String Content){
String makeContent=new String();
StringTokenizer strToken=new StringTokenizer(Content,"
");
String tempToken=null;

while(strToken.hasMoreTokens()){
tempToken=strToken.nextToken();
if(tempToken.indexOf(":")!=0)
makeContent=makeContent+tempToken+"
";
}
return makeContent;
}

//将/n转换成为回车

public String addBr(String Content){
String makeContent=new String();
StringTokenizer strToken=new StringTokenizer(Content,"
");
while(strToken.hasMoreTokens()){
makeContent=makeContent+"
"+strToken.nextToken();
}
return makeContent;
}

//将
转换成为回车/n
public String addCr(String Content){
String makeContent=new String();
StringTokenizer strToken=new StringTokenizer(Content,"
");
while(strToken.hasMoreTokens()){
makeContent=makeContent+"
"+strToken.nextToken();
}
return makeContent;
}


//====================================================================

=====
public boolean getIdentify(String name1,String pwd1)
{
try
{
String sql="select * from club_users where username=" + name1 + "

and password=" + pwd1 + "";
ResultSet rs = executeQuery(sql);
if(rs.next()) { rs.close(); return(true);}
else { rs.close();return(false);}
}catch (Exception e) { return(false);}
}

public void counts(String pagename)
{
executeUpdate("update call_count set counts=counts + 1 where pagenam

e="+pagename+"");

}

//==================张家界市民虚拟社区管理============================

======
public String getDeptSuper(String vp) //取版主
{
String vst="未知";
try{
String sql="select administrator from club_cvcdept where deptno=

"+vp+"";
ResultSet rs = executeQuery(sql);
if(rs.next()) vst=rs.getString(1);
rs.close();
} catch (Exception e) {}
return vst;
}
public String getDeptName(String vp) //取版名
{
String vst="未知";
try{
String sql="select deptnote from club_cvcdept where deptno="+vp

+"";
ResultSet rs = executeQuery(sql);
if(rs.next()) vst=rs.getString(1);
rs.close();
} catch (Exception e) {}
return vst;
}

public String getUserEmail(String vp) //取社区用户email
{
String vst="未知";
try{
String sql="select email from club_users where username="+vp+"

";
ResultSet rs = executeQuery(sql);
if(rs.next()) vst=rs.getString(1);
rs.close();
} catch (Exception e) {}
return vst;
}

public Object getaValue(String vp) //取社区用户email及其他
{
Object vst=null;
try{
String sql=vp;
ResultSet rs = executeQuery(sql);
if(rs.next()) vst=rs.getObject(1);
rs.close();
} catch (Exception e) {}
return vst;
}

public String getsValue(String vp) //取社区用户email及其他
{
String vst="";
try{
String sql=vp;
ResultSet rs = executeQuery(sql);
if(rs.next()) vst=rs.getString(1);
rs.close();
} catch (Exception e) {}
return vst;
}


}//end opDb.java

你可能感兴趣的:(JSP开发)