在JSP中的头部分中隐藏登录凭据

时间:2014-06-10 12:01:44

标签: java jquery jsp servlets

我在标题部分有登录凭据(即电子邮件和密码)。所有页面都包含哪些内容。登录后如何隐藏该登录凭据。我在JSP页面中使用了Servlets代码。我只有JSP页面,Anybody Please帮帮我。

login.jsp
___________********_______

<!DOCTYPE html>
<html>
<head>
<script src="jquery.min.js"></script>
<script>
$(document).ready(function(){
$(".btn1").click(function(){
$("input").hide();
});
});
</script>
</head>
<body  style="background-color: wheat;">
<div>Email<input class="span2" id="logInEmail" type="text">&nbsp; &nbsp;
   Password<input class="span2" id="logInPass" type="password"><br></div>
<a class="btn1" href="welcome.jsp">Sign in</a>
</body>
</html>
________************_____________

index.jsp
_________************____________
<!DOCTYPE html>
<html>
<head>
<%@include file="login.jsp" %>
</head>
<body>
<p>This is index page</p>
<p>This is for paragraph</p>
</body>
</html>
____________************_________

welcome.jsp
_____________*************________
<!DOCTYPE html>
<html>
<head>
<%@include file="login.jsp" %>
</head>
<body>
<h4>Welcome success</h4>
<p>Hello world</p>
</body>
</html>

 *******************

1 个答案:

答案 0 :(得分:0)

使用方法=&#34;发布&#34;在验证成功块中的会话中存储电子邮件。

 if valid user
 HttpSession session=request.getSession();
 session.setAttribute("email", emailid);

在任何页面中获取emailid

String email=(String)session.getAttribute("email");
相关问题