登陆实例(JSP+Servlet+JavaBean) 转
登陆是我们在实际应用中经常用到的,我在这边举个简单的登陆例子,作为抛砖引玉吧!
程序结构如下:
采用JSP+Servlet+JavaBean
1.数据库结构(为简便这边采用access,实际应用中建议采用其他数据库如MySQL,MSSQL等)
==============================
uname 用户名 文本型
pword 密码 文本型
初始数据uname :ceun pword :123
==============================
2.视图(JSP)
<%...@page contentType="text/html"%>
<%...@page pageEncoding="UTF-8"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>登陆</title>
</head>
<body>
<center><br><br><br>
<p><form action="<%=request.getContextPath ()%>/CheckServlet" method="post">
<table width="259" border="1" cellpadding="0" cellspacing="0" bordercolor="#0099FF">
<tr align="center">
<td height="20" colspan="2"><span class="style1">登陆</span></td>
</tr>
<tr>
<td width="50" height="20">用户名</td>
<td width="161" align="left"><input name="uname" type="text" id="uname" size="19"></td>
</tr>
<tr>
<td height="20">密码</td>
<td align="left"><input name="pword" type="password" id="pword" size="20"></td>
</tr>
<tr align="center">
<td colspan="2"><input type="submit" name="Submit" value="提交">
<input type="reset" name="Submit" value="重置"></td>
</tr>
</table></form></p>
</center>
</body>
</html>
3.Servlet
/**//*
* CheckServlet.java
*@author Java619
* Created on 2006年3月25日, 下午6:05