收 藏 投 稿 繁 体 RSS 
站长吧-中国站长学习与交流的网站
首 页 运 营 学 院 建 站 论 坛
Web master8.net  
 网站运营  
  欢迎在本站发布信息,在线投递稿件请点这里。编辑QQ:4908220,欢迎联系交流。
业界动态 创业故事 推广研究 策划盈利 电子商务 企业平台
  站长工具
SEO查询 Whois查询 Pr查询 域名查询 IP查询 网页编辑器
 建站服务  
  如有建站意向,请尽快联系我们,以便安排时间... 建站服务 QQ4908220 QQ:4908220
作品展示 服务范围 服务流程 服务报价 联系方式 付款方式
文章正文  » 您的当前位置: 首页 >> 学院 >> 程序开发 >> JSP
jsp留言本示例
  来源:互联网 | 时间:2005-09-01 | 浏览:   相关评论 | 报告错误 | 发布文章
【字号: | | 】 【背景色 杏仁黄 秋叶褐 胭脂红 芥末绿 天蓝 雪青 灰 银河白(默认色)
sp"/>
<%
if(session.getAttribute("error")!=null)
{
String serror=(String)session.getAttribute("error");
if(serror.equals("1"))
{
out.println("这个名字已经有人注册了,请返回重新注册");
}
if(serror.equals("2"))
{
out.println("没有找到这个用户,请您注册后登陆");
}
if(serror.equals("3"))
{
out.println("您输入的用户名跟密码不正确");
}
}
%>
<jsp:include page="foot.jsp"/>
</body>
</html>




foot.jsp>>>>>>>>>>>>>>>>>>>>>>>>>

<%@ page contentType="text/html; charset=gb2312" %>
<html>
<head>
<title>
foot
</title>
</head>
<body>
<jsp:useBean id="master" scope="session" class="tools.master"/>
<table width="650" height="45" border="0" cellspacing="0" cellpadding="0" align="center">
<tr height=10 >
<td></td>
</tr>
<tr height=1 class=table003>
<td></td>
</tr>
<tr>
<td align="center" class=jnfont5><a href="<%=master.getWangzhanshouye()%>">网站首页</a> | <a href="<%=master.getWangzhanjianjie()%>">网站简介</a> | <a href="mailto:<%=master.getLianxiwomen()%>">联系我们</a> | <a href="<%=master.getGuanyuwomen()%>">关于我们</a> | <a href="<%=master.getYouqinglianjie()%>">友情链接</a> <br>
</td>
</tr>
</table>
</body>
</body>
</html>



head.jsp>>>>>>>>>>>>>>>>>>>
<%@ page contentType="text/html; charset=gb2312" %>
<html>
<head>
<title>
head
</title>
</head>
<body>

<jsp:useBean id="master" scope="session" class="tools.master"/>
<table width="650" border="0" cellpadding="0" cellspacing="0" align="center" class="table004">
<tr>
<td><table border="0" width="650" cellspacing="0" cellpadding="3" class="table002">
<tr>
<td width="233" height="38">>> <a href="<%=master.getWangzhanshouye()%>"><img src=images/home.gif align=absmiddle border=0 alt=返回主页></a></td>
<td width="*"><a href="post.jsp"><img src=images/post.gif alt="发新留言" border=0 align=absmiddle></a></td>
<td width="320" style="letter-spacing: 1" align="right"><p align="center">

<%
if(session.getAttribute("loginname")==null)
{
%>
<a href="show.jsp">首页</a>:<a href="login.jsp">登陆</a>:<a href="reg.jsp">注册</a>
<%
}
else
{
if(session.getAttribute("adminname")!=null)
{
%>
<a href="show.jsp">首页</a>: <%=session.getAttribute("loginname")%>欢迎您的登陆! 
<a href="edit.jsp?name=<%=session.getAttribute("loginname")%>">编辑个人信息</a> 
<a href="/htmanage/admin_main.jsp">管理</a>
<%
}
else
{
%>
<a href="show.jsp">首页</a>: <%=session.getAttribute("loginname")%>欢迎您的登陆! 
<a href="edit.jsp?name=<%=session.getAttribute("loginname")%>">编辑个人信息</a> 
<%

}
}
%>
</td>
</tr>
</table></td>
</tr>
</table>
</body>
</body>
</html>




index.jsp>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
<%@ page contentType="text/html; charset=gb2312" %>
<html>
<head>
<title>
index
</title>
</head>
<body bgcolor="#ffffff">
<h1>

<jsp:forward page="show.jsp"/>
</h1>
</body>
</html>



login.jsp>>>>>>>>>>>>>>>>>>

<%@ page contentType="text/html; charset=GBK" %>
<html>
<head>
<title>
login
</title>
</head>
<body>
<jsp:include page="head.jsp"/>
<form name="form1" action="servlet_login" method="post">
<table width="600" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<th width="313" scope="col"><div align="right">姓名:</div></th>
<th width="26" scope="col"> </th>
<th width="261" colspan="4" scope="col"><div align="left">
<input name="tname" type="text" id="tname" maxlength="10">
</div></th>
</tr>
<tr>
<th scope="col"><div align="right">密码:</div></th>
<th scope="col"> </th>
<th colspan="4" scope="col"><div align="left">
<input name="tpass" type="password" id="tpass" maxlength="10">
</div></th>
</tr>
<tr>
<th scope="col"><div align="right">
<input type="button" name="buttonsubmit" value="提交" onClick="chick();">
</div></th>
<th scope="col"> </th>
<th colspan="4" scope="col"><div align="left">
<input type="reset" name="Submit" value="重置">
</div></th>
</tr>
<tr>
</tr>
</table>
</form>

<script language="javascript">
function chick()
{
if(document.form1.tname.value=="")
{
alert("姓名不可为空!!");
document.form1.tname.focus();
}
else if(document.form1.tpass.value=="")
{
alert("密码不可为空!!");
document.form1.tpass.focus();
}
document.form1.submit();
}
</script>
<jsp:include page="foot.jsp"/>
</body>

</html>



post.jsp>>>>>>>>>>>>>>>>>>>>
<%@ page contentType="text/html; charset=GBK" %>
<%@ page import="java.sql.*"%>
<html>
<head>
<title>
post
</title>
</head>
<body>



<form name="form1" method="post" action="servlet_post">
<table width="600" border="0" align="center" cellspacing="0" bordercolor="#FFFFFF">
<tr>
<th width="649" height="121" colspan="2" scope="col">


<%--<jsp:useBean id="dataBean" scope="session" class="connection.Data"/>--%>
<%
if(session.getAttribute("loginname")==null)
{

//Connection conn=dataBean.getConn();
//Statement stme=conn.createStatement();
//ResultSet rs=stme.executeUpdate("select *")
%>
<table width="600">
<tr>
<th width="203" scope="col"><div align="right">姓名 </div></th>
<th width="385" scope="col"><div align="left">
<input name="tname" type="text" maxlength="10">
</div></th>
</tr>
<tr>
<td><div align="right"><strong>密码   </strong></div></td>
<td><input name="tpass" type="password" maxlength="10"></td>
</tr>
</table>
<script language="javascript">
function chick()
{
if(document.form1.tname.value=="")
{
alert("您还没有登陆,需要输入用户名");
}
else if(document.form1.tpass.value=="")
{
alert("您还没有登陆,请输入密码");
}
else if(document.form1.tbt.value=="")
{
alert("请输入留言标题");
}
else if(document.form1.tnr.value=="")
{
alert("请输入留言内容");
}
document.form1.submit();
}
</script>
<%

}
else
{ String tempname=(String)session.getAttribute("loginname");

%>

<script language="javascript">
function chick()
{
if(document.form1.tbt.value=="")
{
alert("请输入留言标题");
}
else if(document.form1.tnr.value=="")
{
alert("请输入留言内容");
}
document.form1.submit();
}
</script>


<table width="600">

<tr>
<th colspan="2" scope="col"><%=tempname%>,欢迎您的留言</th>
</tr>
<%
}
%>
<tr>
<td width="200"><div align="right"><strong>标题 </strong></div></td>
<td width="388"><input name="tbt" type="text" id="tbt">
</td>
</tr>
<tr>
<td><div align="right"><strong>内容 </strong></div></td>
<td><textarea name="tnr" id="tnr"></textarea></td>
</tr>
<tr>
<td><div align="right">
</div></td>
<td><input type="button" name="ss" value="提交" onClick="chick();">   
<input type="reset" name="Submit" value="重填"></td>
</tr>
</table></th>
</tr>
</table>
</form>
</body>
</html>





reg.jsp>>>>>>>>>>>>>>>>>>>>>>>>>>>>
<%@ page contentType="text/html; charset=gb2312" %>
<html>
<head>
<title>
reg
</title>
</head>
<body>
<jsp:include page="head.jsp"/>
<table width="600" border="0" align="center" cellspacing="0">
<tr>
<td> </td>
</tr>
<tr>
<td height="73">

<form name="form1" method="post" action="servlet_reg">
<table width="352" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="129">姓名:</td>
<td width="223"><input name="tname" type="text" id="tname" maxlength="10"></td>
</tr>
<tr>
<td>密码:</td>
<td><input name="tpass1" type="password" id="tpass1" maxlength="10"></td>
</tr>
<tr>
<td>确认密码:</td>
<td><input name="tpass2" type="password" id="tpass2" maxlength="10"></td>
</tr>
<tr>
<td height="14">性别:</td>
<td>男
<input name="请不要发表含有不雅言语的内容" type="radio" value="男" checked>

<input type="radio" name="请不要发表含有不雅言语的内容" value="女"> 
 <a href="userhead.html">查看头像</a></td>
</tr>
<tr>
<td>头像选择:</td>
<td><select name="ttouxiang" id="ttouxiang">
<option>1.gif</option>
<option>2.gif</option>
<option>3.gif</option>
<option>4.gif</option>
<option>5.gif</option>
<option>5.gif</option>
<option>6.gif</option>
<option>7.gif</option>
<option>8.gif</option>
<option>9.gif</option>
<option>10.gif</option>
<option>11.gif</option>
<option>12.gif</option>
<option>13.gif</option>
<option>14.gif</option>
<option>15.gif</option>
<option>16.gif</option>
<option>17.gif</option>
<option>18.gif</option>
<option>19.gif</option>
<option>20.gif</option>
</select></td>
</tr>
<tr>
<td>Email:</td>
<td><input name="tmail" type="text" id="tmail" maxlength="50"></td>
</tr>
<tr>
<td>Oicq:</td>
<td><input name="toicq" type="text" id="toicq" maxlength="9"></td>
</tr>
<tr>
<td><div align="center">
<input type="button" name="Submit" value="提交" onClick="chick();">
</div></td>
<td><input type="reset" name="Submit" value="重置"></td>
</tr>
</table>

</form>

</td>
</tr>
<tr>
<td> </td>
</tr>
</table>
</form>
<jsp:include page="foot.jsp"/>
</body>

<script language="javascript">
function chick()
{
if(document.form1.tname.value=="")
{
alert("姓名不可为空!!");
document.form1.tname.focus();
}
else if(document.form1.tpass1.value=="")
{
alert("密码不可为空!!");
document.form1.tpass1.focus();
}
else if(document.form1.tpass2.value=="")
{
alert("密码确认不可为空!!");
document.form1.tpass2.focus();
}
else if(document.form1.tmail.value=="")
{
alert("Email不可为空!!");
document.form1.tmail.focus();
}
else if(document.form1.toicq.value=="")
{
alert("Oicq不可为空!!");
focument.form1.toicq.focus();
}
else if(!document.form1.tpass1.value.equals(document.form1.tpass2.value))
{
alert("请确认两次密码必须输入一致!!");
document.form1.tpass1.focus();
}
else
{
document.form1.submit();
}
}

</script>
</html>



show.jsp>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
<%@ page contentType="text/html; charset=GBK" %>
<%@ page import ="java.sql.* "%>

<%
//定义一个一页显示多少条数据
int intPageSize;
//定义一个总记录数
int intRowCount;
//定义一个总页数
int intPageCount;
//准备显示的页
int intPage;
//取得页书号的变量
String strPage;

//Data连接数据库类
connection.Data data=new connection.Data();

//connection连接数据哭类
Connection conn;
//Statement操作数据库类
Statement stme;
Statement stme2;
//ResultSet操作记录机类
ResultSet rslyxx;
ResultSet rsuserinfo;
//每页显示的记录数
intPageSize=8;

//取得页面号
if(request.getParameter("page")==null)
{
intPage=1;
}
else
{
strPage=(String)request.getParameter("page");
intPage=Integer.parseInt(strPage);
if(intPage<1)
{
intPage=1;
}
}
intPageCount=0;

conn=data.getConn();
stme=conn.createStatement();
rslyxx=stme.executeQuery("select * from lyxx");
rslyxx.last();
//获得总记录数
intRowCount=rslyxx.getRow();
//获得总页数
intPageCount=(intRowCount+intPageSize-1)/intPageSize;
//如果每页显示的记录数大约总记录数
if(intPageSize>intRowCount)
{
intPageSize=intRowCount;
}
if(intPage>intPageCount)
{
intPage=intPageCount;
}


%>
<html>
<head>
<title>
show
</title>
</head>
<body>
<p>
<jsp:include page="head.jsp"/>
</p>
<table width="600" align="center" cellspacing="0">
<tr>
<th scope="col">
<%--显示表格或者是汉字提示有无记录--%>


<%
if(intRowCount<1)
{

%>
<table width="600" cellspacing="0">
<tr>
<th scope="col">暂时还没有人在此留言</th>
</tr>
</table>


</th>
</tr>
<tr>
<td>
<%
}
else
{
//将指针定位到每页最后一位上
rslyxx.absolute(intRowCount-(intPage-1)*intPageSize);
//将指针定位到每页第一位上
// rslyxx.absolute((intPage-1) * intPageSize + 1);
//显示数据

int i = 0;

while(i<intPageSize && !rslyxx.isBeforeFirst())
{
stme2=conn.createStatement();
rsuserinfo=stme2.executeQuery("select * from userinfo where username='"+rslyxx.getString("lyuser")+"'");
rsuserinfo.next();
%>

<table width="713" border="0" cellspacing="0">
<tr>
<th width="146" scope="col"><%=rslyxx.getString("lyuser")%></th>
<th colspan="4" scope="col">
<table width="600">
<tr>
<th width="513" scope="col"><%=rslyxx.getString("lybt")%></th>
<th width="75" scope="col">
<%
if(session.getAttribute("loginname")!=null)
{
String tempname=(String)session.getAttribute("loginname");
tempname.trim();
String dataname=(String)rsuserinfo.getString("username");
if(tempname.equals(dataname.trim()))
{
%>
<a href="editnr.jsp?id=<%=rsuserinfo.getString("id")%>">编辑</a>
<%
}
else
{
if(session.getAttribute("adminname")!=null)
{
%>
<a href="editnr.jsp?id=<%=rsuserinfo.getString("id")%>">编辑</a>
<%
}
}
}
%>
</th>
</tr>
</table></th>
</tr>
<tr>
<td align="center" valign="top"><img src="pic/<%=rsuserinfo.getString("userhead").trim()%>" width="100" height="100"></td>
<td colspan="4"><%=rslyxx.getString("lynr")%></td>
</tr>
<tr>
<td>注册时间:<%=rsuserinfo.getString("userdate")%></td>
<td width="111">性别:</td>
<td width="111">Oicq:<%=rsuserinfo.getString("useroicq")%></td>
<td width="150">Email:<%=rsuserinfo.getString("usermail")%></td>
<td width="185">发帖时间:<%=rslyxx.getString("lydate")%></td>
</tr>
</table>
<%
rsuserinfo.close();
stme2.close();
rslyxx.previous();
i++;
}
}
stme.close();
conn.close();

%>






</td>
</tr>
<tr>
<td><table width="250" border="0" align="right" cellspacing="0">
<tr>
<th width="44" scope="col">第<%=intPage%>页</th>
<th width="44" scope="col">共<%=intPageCount%>页</th>
<th width="55" scope="col"><a href="show.jsp?page=<%=intPage-1%>">上一页</a></th>
<th width="49" scope="col"><a href="show.jsp?page=<%=intPage+1%>">下一页</a></th>
</tr>
</table></td>
</tr>
</table>

<p>
<jsp:include page="foot.jsp"/>
</p>
</body>
</html>









userhead.html>>>>>>>>>>>>>>>>>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>

<body>
<table width="600" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><div align="center"><img src="pic/1.gif" width="100" height="100"></div></td>
<td><div align="center"><img src="pic/2.gif" width="100" height="100"></div></td>
<td><div align="center"><img src="pic/3.gif" width="100" height="100"></div></td>
<td><div align="center"><img src="pic/4.gif" width="100" height="100"></div></td>
<td><div align="center"><img src="p
分页 [1] [2] [3] [4] [5]
master8
  • 上一篇:抓图实战12招大放送
  • 下一篇:万维网创始人博客处女秀

  • 我要投稿  打印本文  推荐本文  加入收藏  返回顶部  关闭窗口
    搜模板(www.somoban.com) 原创网站模板交易平台
    阿里妈妈再掀疯狂采购风,网站广告位严重告急,急召天下站长
    基于PHP+MySQL的整站、模块、插件开发等或者按需求实现相应功能;
基于各PHP主流建站系统CMS,BBS,BLOG等的模板定制,完全手写代码;
整站数据迁移或备份恢复;网页代码优化、重构;整站常规SEO优化;网站技术支持;
点击了解详情...
    站长论坛
    • 验证码: