简体   繁体   English

使用Jave EE提供的登录表单身份验证在JSP页面中获取会话变量

[英]Getting session variable in JSP page using Login Form Authentication provided by Jave EE

I'm following this guide Securing web application in order to create login form authentication in my web app. 我正在遵循本指南保护Web应用程序安全 ,以便在我的Web应用程序中创建登录表单身份验证。 Unfortunately something don't satisfy me. 不幸的是我不满意。 I'm looking for a variable that I could use in a jsp page that say the user is logged on or not. 我正在寻找一个可以在jsp页面中使用的变量,该变量表示用户是否登录。 for istance 出于立场

<c:if test=${userIsLogged}>

</c:if

Does exist a way to get a variable linked to the session? 是否存在使变量链接到会话的方法?

Test this: 测试一下:

<c:if test=${not empty pageContext.request.userPrincipal}>

    User login:  ${pageContext.request.userPrincipal.name}

</c:if

NOTE: This only works if you use Container login (JAAS). 注意:仅当您使用容器登录(JAAS)时,此方法才有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM