JSP实现简单的用户登录并显示出用户信息的方法
更新时间:2015年02月05日 10:39:48 作者:Bo年再无木小白
这篇文章主要介绍了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>
<%
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>
<%
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程序设计有所帮助。
相关文章
JSP连接MySql/MS SQL Server/Oracle数据库连接方法[整理]
这个经常整理更新2008-10-10
JSP开发中Apache-HTTPClient 用户验证的实例详解
这篇文章主要介绍了JSP开发中Apache-HTTPClient 用户验证的实例详解的相关资料,这里提供实例帮助大家学习理解这部分内容,需要的朋友可以参考下2017-08-08
在JSTL EL中处理java.util.Map,及嵌套List的情况
在EL中,方括号运算符用来检索数组和集合的元素。对于实现 java.util.Map 接口的集合,方括号运算符使用关联的键查找存储在映射中的值。2009-03-03


最新评论