JSP實現(xiàn)簡單的用戶登錄并顯示出用戶信息的方法
更新時間:2015年02月05日 10:39:48 作者:Bo年再無木小白
這篇文章主要介紹了JSP實現(xiàn)簡單的用戶登錄并顯示出用戶信息的方法,通過簡單的登陸及登陸顯示頁面實現(xiàn)這一功能,具有一定參考借鑒價值,需要的朋友可以參考下
本文實例講述了JSP實現(xiàn)簡單的用戶登錄并顯示出用戶信息的方法。分享給大家供大家參考。具體實現(xiàn)方法如下:
login.jsp
復(fù)制代碼 代碼如下:
<%@ 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 用于顯示用戶信息
復(fù)制代碼 代碼如下:
<%@ 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程序設(shè)計有所幫助。
您可能感興趣的文章:
- jsp+dao+bean+servlet(MVC模式)實現(xiàn)簡單用戶登錄和注冊頁面
- 使用JSP實現(xiàn)簡單的用戶登錄注冊頁面示例代碼解析
- jsp實現(xiàn)用戶自動登錄功能
- jsp實現(xiàn)簡單用戶7天內(nèi)免登錄
- servlet+jsp實現(xiàn)過濾器 防止用戶未登錄訪問
- JSP Spring防止用戶重復(fù)登錄的實現(xiàn)方法
- JavaWeb實現(xiàn)用戶登錄注冊功能實例代碼(基于Servlet+JSP+JavaBean模式)
- JSP實現(xiàn)用戶登錄、注冊和退出功能
- jsp基于XML實現(xiàn)用戶登錄與注冊的實例解析(附源碼)
- 在jsp中用bean和servlet聯(lián)合實現(xiàn)用戶注冊、登錄
- 關(guān)于JSP用戶登錄連接數(shù)據(jù)庫詳情
相關(guān)文章
JSP使用Servlet作為控制器實現(xiàn)MVC模式實例詳解
這篇文章主要介紹了JSP使用Servlet作為控制器實現(xiàn)MVC模式的方法,以完整實例形式較為詳細(xì)的分析了MVC模式的原理及Servlet實現(xiàn)MVC模式的原理與相關(guān)注意事項,需要的朋友可以參考下2015-09-09jsp Response對象頁面重定向、時間的動態(tài)顯示
response對象主要用于對客戶端的請求進(jìn)行回應(yīng),將web服務(wù)器處理后的結(jié)果發(fā)回給客戶端,封裝了jsp產(chǎn)生的響應(yīng),并發(fā)送到客戶端響應(yīng)客戶端的請求,請求的數(shù)據(jù)可以是各種數(shù)據(jù)類型,甚至是文件2021-07-07