使用JSP实现用户登录

本文详细介绍了如何使用JSP实现用户登录、注册和退出功能。涉及数据库设计,如创建用户表,以及页面设计,包括登录、注册、欢迎页面和退出逻辑处理页面。通过JDBC连接Oracle数据库,处理登录和注册的逻辑,确保数据验证和用户交互的正确性。
摘要由CSDN通过智能技术生成

本文讲述使用JSP实现用户登录,包括用户登录、注册和退出功能等。

1.系统用例图

2.页面流程图

3.数据库设计

本例使用oracle数据库

创建用户表

包括id,username,password和email,共4个字段

 

[sql]  view plain  copy
 
  1. -- Create table  
  2. create table P_USER  
  3. (  
  4.   id       VARCHAR2(50) not null,  
  5.   username VARCHAR2(20),  
  6.   password VARCHAR2(20),  
  7.   email    VARCHAR2(50)  
  8. )  
  9. tablespace USERS  
  10.   pctfree 10  
  11.   initrans 1  
  12.   maxtrans 255  
  13.   storage  
  14.   (  
  15.     initial 64  
  16.     minextents 1  
  17.     maxextents unlimited  
  18.   );  
  19. -- Add comments to the table   
  20. comment on table P_USER  
  21.   is '用户表';  
  22. -- Add comments to the columns   
  23. comment on column P_USER.id  
  24.   is 'id';  
  25. comment on column P_USER.username  
  26.   is '用户名';  
  27. comment on column P_USER.password  
  28.   is '密码';  
  29. comment on column P_USER.email  
  30.   is 'email';  

 

4.页面设计

 

4.1登录页面

login.jsp

 

[html]  view plain  copy
 
  1. <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>  
  2. <%  
  3. String path = request.getContextPath();  
  4. String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";  
  5. %>  
  6.   
  7. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">  
  8. <html>  
  9.   <head>  
  10.     <base href="<%=basePath%>">  
  11.       
  12.     <title>登录页面</title>  
  13.       
  14.     <meta http-equiv="pragma" content="no-cache">  
  15.     <meta http-equiv="cache-control" content="no-cache">  
  16.     <meta http-equiv="expires" content="0">      
  17.     <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">  
  18.     <meta http-equiv="description" content="This is my page">  
  19.     <!-- 
  20.     <link rel="stylesheet" type="text/css" href="styles.css"> 
  21.     -->  
  22.   </head>  
  23.     
  24.   <body>  
  25.     <form action="login_action.jsp" method="post">  
  26.         <table>  
  27.             <tr>  
  28.                 <td colspan="2">登录窗口</td>  
  29.             </tr>  
  30.             <tr>  
  31.                 <td>用户名:</td>  
  32.                 <td><input type="text" name="username" />  
  33.                 </td>  
  34.             </tr>  
  35.             <tr>  
  36.                 <td>密码:</td>  
  37.                 <td><input type="password" name="password" />  
  38.                 </td>  
  39.             </tr>  
  40.             <tr>  
  41.                 <td colspan="2"><input type="submit" value="登录" /> <href="register.jsp">注册</a>  
  42.                 </td>  
  43.             </tr>  
  44.         </table>  
  45.     </form>  
  46. </body>  
  47. </html>  

页面效果

 

  • 3
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值