jsp+jdbc+Servlet实现登录系统(.jsp)

index.jsp

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">    
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
  </head>
  
  <body>
    This is my JSP page. <br>
    
    <a href="login/login.jsp">登录</a> <br>
    <a href="user/reg.jsp">添加用户</a> <br>
     <a href="QueryAllUserServlet">用户信息的其他管理操作,包括了查询所有,修改、删除</a> <br>
    
  </body>
</html>

login.jsp

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'login.jsp' starting page</title>
    
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">    
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->


  </head>
  
  <body>
    This is my login JSP page. <br>
    
    <%
    String username =  (String) session.getAttribute("loginUser");
    if (username != null) {
    out.println("当前登录用户:" + username);
    } else {
    out.println("未登录!");
    }
    %>
 
     <form action="LoginUserServlet" method="post" >
    <table align="center">
    <tr>
    <td>Username:</td>
    <td><input type="text" name="username"></td>
    </tr>
    <tr>
    <td>Passwrod:</td>
    <td><input type="password" name="password"></td>
    </tr>
   
    <tr>
    <td> <input type="submit" value="Submit"> </td>
    <td> <input type="reset" value="Reset"> </td>
    </tr>
    </table>
    
    </form>
  </body>
</html>

loginfail.jsp

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'login.jsp' starting page</title>
    
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">    
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->


  </head>
  
  <body>
    This is my login JSP page. <br>
    
    <%= request.getParameter("username") %> 登录失败!请重新登陆!
    
     <form action="LoginUserServlet" method="post" >
    <table align="center">
    <tr>
    <td>Username:</td>
    <td><input type="text" name="username"></td>
    </tr>
    <tr>
    <td>Passwrod:</td>
    <td><input type="password" name="password"></td>
    </tr>
   
    <tr>
    <td> <input type="submit" value="Submit"> </td>
    <td> <input type="reset" value="Reset"> </td>
    </tr>
    </table>
    
    </form>
  </body>
</html>

loginSucc.jsp

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'loginSucc.jsp' starting page</title>
    
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">    
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->


  </head>
  
  <body>
    This is my login Succ JSP page. <br>
    
   欢迎  <%= request.getParameter("username") %>     
         
         登录成功! <br>
     <a href="user/reg.jsp">添加用户</a> <br>
     
     <a href="QueryAllUserServlet">用户信息的其他管理操作,包括了查询所有,修改、删除</a> <br>
  </body>
</html>

查询页面listuser.jsp

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>


<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'listUser.jsp' starting page</title>
    
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">    
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->

<script type="text/javascript" >
function del() {
if (confirm("Delete????")) {
return true;
}
return false;
}

</script>


  </head>
  
  <body>
    This is my list JSP page. 55555555 <br>
    
    
    <form action="QuerUserServlet" method="post">
    Username: <input type="text" name="username" />
    Age: &gt; <input type="text" name="minAge" /> &lt; <input type="text" name="maxAge" />
    <input type="submit" value="Query">
    </form>
    
    <table border="2" cellspacing="0" cellpadding="0">
    <tr> 
    <td>NO</td>
    <td>Username</td>
    <td>Pwd</td>
    <td>age</td>
    <td>Update</td>
    <td>Del</td>
    </tr>
   
    <c:forEach items="${requestScope.list}" var="usr" varStatus="status">
    <tr>
    <td>${status.count } </td>
    <td> ${ usr.username } </td>
    <td>${usr.password} </td>
    <td>${usr.age } </td>
    <td><a href="ToUpdateUserServlet?id=${usr.id }">修改</a> </td>
    <td><a href="DeleteUserServlet?id=${usr.id }" οnclick="return del();">删除</a> </td>
                
    </tr>
</c:forEach>
   
    </table>

  </body>
</html>

注册页面reg.jsp

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'reg.jsp' starting page</title>
    
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">    
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->


  </head>
  
  <body>
    This is my reg JSP page. <br>
    
     <form action="RegUserServlet" method="post" >
    <table align="center">
    <tr>
    <td>Username:</td>
    <td><input type="text" name="username"></td>
    </tr>
    <tr>
    <td>Passwrod:</td>
    <td><input type="password" name="password"></td>
    </tr>
   
    <tr>
    <td>Age:</td>
    <td><input type="text" name="age"></td>
    </tr>
   
    <tr>
    <td>Hobs:</td>
    <td>
    <input type="checkbox" name="hobs" value="0" checked="checked"> 篮球
    <input type="checkbox" name="hobs" value="1" > 足球
    <input type="checkbox" name="hobs" value="2" > 排球
    </td>
    </tr>
   
    <tr>
    <td> <input type="submit" value="Submit"> </td>
    <td> <input type="reset" value="Reset"> </td>
    </tr>
    </table>
    
    </form>
    
  </body>
</html>

注册失败refail.jsp

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">


<title>My JSP 'regSucc.jsp' starting page</title>


<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->


</head>


<body>
This is my reg fail JSP page.
<br>


</body>
</html>

注册成功regsucc.jsp

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">


<title>My JSP 'regSucc.jsp' starting page</title>


<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->


</head>


<body>
This is my reg succ JSP page.
<br>



你好 <%= request.getParameter("username") %> ,注册成功!

<br>

<a href="../index.jsp">首页</a>


</body>
</html>

用户信息更新update.jsp

<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'updateUser.jsp' starting page</title>
    
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">    
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->


  </head>
  
  <body>
    This is my udpate JSP page. <br>
    
     <form action="UpdateUserServlet" method="post" >
     
      <input type="hidden" name="id" value="${usr.id }">
     
    <table align="center">
    <tr>
    <td>Username:</td>
    <td><input type="text" name="username" value="${usr.username }"></td>
    </tr>
   
    <tr>
    <td>Age:</td>
    <td><input type="text" name="age" value="${usr.age }"></td>
    </tr>
   
   
    <tr>
    <td> <input type="submit" value="Update"> </td>
    <td> <input type="reset" value="Reset"> </td>
    </tr>
    </table>
    
    </form>
    
  </body>
</html>

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值