没有合适的资源?快使用搜索试试~ 我知道了~
登录模块代码JSP+MySQL
1星 需积分: 9 41 下载量 173 浏览量
2010-05-13
19:51:39
上传
评论
收藏 9KB TXT 举报
温馨提示
试读
11页
关于JSP与MySQL的简单登录模块代码
资源推荐
资源详情
资源评论
在JSP环境下,数据库为SQL,登录模块,经测试合格
index.jsp//索引页面
<%
int i;
//初始化,用于保存Cookie中的用户名、密码
String C_username="";
String C_password="";
//获取全部Cookie
Cookie c[]=request.getCookies();
for(i=0;i<c.length;i++)
{
//在Cookie中查找用户名、密码,如果找到,则分别将其赋值给用户名、密码变量
if("username".equals(c[i].getName()))
C_username=c[i].getValue();
if("password".equals(c[i].getName()))
C_password=c[i].getValue();
}
if(!"".equals(C_username) && !"".equals(C_password))
{
//Cookie中有用户名、密码,将用户名、密码提交到验证页面
response.sendRedirect("check.jsp?username="+C_username+"password="+C_password);
}
else
{
//Cookie中没有用户名、密码,跳转到登录页面
%>
<jsp:forward page="login.jsp" />
<%
index.jsp//索引页面
<%
int i;
//初始化,用于保存Cookie中的用户名、密码
String C_username="";
String C_password="";
//获取全部Cookie
Cookie c[]=request.getCookies();
for(i=0;i<c.length;i++)
{
//在Cookie中查找用户名、密码,如果找到,则分别将其赋值给用户名、密码变量
if("username".equals(c[i].getName()))
C_username=c[i].getValue();
if("password".equals(c[i].getName()))
C_password=c[i].getValue();
}
if(!"".equals(C_username) && !"".equals(C_password))
{
//Cookie中有用户名、密码,将用户名、密码提交到验证页面
response.sendRedirect("check.jsp?username="+C_username+"password="+C_password);
}
else
{
//Cookie中没有用户名、密码,跳转到登录页面
%>
<jsp:forward page="login.jsp" />
<%
}
%>
login.jsp//登录页面
//charset要改为gbk
<title>登录界面</title>
</head>
<body>
<center>
<h1>登录页面</h1>
<hr>
<form action="check.jsp" method="post">
<table>
<tr>
<td>用户名:</td>
<td><input type="text" name="username" /></td>
</tr>
<tr>
<td>密 码:</td>
<td><input type="password" name="password" /></td>
</tr>
<tr>
<td>Cookie选项:</td>
<td>
<input type="radio" name="cookie" value="nosave" checked>不保存
<input type="radio" name="cookie" value="save">保存1分钟
</td>
</tr>
<tr>
<td colspan="2" align="center">
%>
login.jsp//登录页面
//charset要改为gbk
<title>登录界面</title>
</head>
<body>
<center>
<h1>登录页面</h1>
<hr>
<form action="check.jsp" method="post">
<table>
<tr>
<td>用户名:</td>
<td><input type="text" name="username" /></td>
</tr>
<tr>
<td>密 码:</td>
<td><input type="password" name="password" /></td>
</tr>
<tr>
<td>Cookie选项:</td>
<td>
<input type="radio" name="cookie" value="nosave" checked>不保存
<input type="radio" name="cookie" value="save">保存1分钟
</td>
</tr>
<tr>
<td colspan="2" align="center">
剩余10页未读,继续阅读
资源评论
- lygzxjj2012-11-18有错误,功能有的不能使用
zhabeyond
- 粉丝: 0
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功