当前位置:首页 > JSP教程 > JSP常见问题

JSP实现简单的用户登录并显示出用户信息的方法

本文实例讲述了jsp实现简单的用户登录并显示出用户信息的方法。分享给大家供大家参考。具体实现方法如下:

login.jsp

复制代码 代码如下:
<%@ page language="java" import="java.util.*" pageencoding="gb18030"%> 
<% 
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> 
  </head> 
   
  <body> 
  <form action="login_success.jsp" method = "post"> 
   用户名:<input type ="text" name = "username"/><br> 
   密码:<input type = "password" name ="password"><br> 
   <input type ="submit" value="提交"/>  
   </form> 
  </body> 
</html>

login_success.jsp 用于显示用户信息

复制代码 代码如下:
<%@ page language="java" import="java.util.*" pageencoding="gb18030"%> 
<% 
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> 
  </head> 
   
  <body> 
  <% 
  string uname = request.getparameter("username"); 
  string pwd = request.getparameter("password"); 
  out.println(uname); 
  out.println(pwd); 
   %> 
  </body> 
</html>

希望本文所述对大家的jsp程序设计有所帮助。



【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!

相关教程推荐

其他课程推荐