如何从servlet/jsp获取登录属性 [英] How to get login attributes from a servlet/jsp

查看:90
本文介绍了如何从servlet/jsp获取登录属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近,我一直在为在Glassfish v3上运行的Web应用程序实现安全性.我通过设置基本身份验证成功设法保护了一些资源,如下所示:

Lately I've been working on implementing security for my web application, running on a Glassfish v3. I successfully managed to secure some resources by setting a basic authentication up like following:

<login-config>
<auth-method>BASIC</auth-method>
<realm-name>vcards-admin</realm-name>
</login-config>

现在,我想知道如何获取登录提示中引入的用户名,以影响用户的实际数据.我以为可以有一个会话属性来获取那段数据,但是我不知道它是哪一个.

Now I was wondering how to get the user name introduced on the login prompt to fecth the actual data of the user. I thought there could be a session attribute to get that piece of data, but I don't know which one it is.

我对会话属性有误吗?还有其他方法可以访问该登录信息吗?

Am I wrong about the session attribute? Is there any other way to access that login information?

谢谢.

推荐答案

等效于JSP EL:

${pageContext.request.userPrincipal.name}
<!-- or -->
${pageContext.request.remoteUser}

这篇关于如何从servlet/jsp获取登录属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆