0

So I have a simple JSP web app running that is composed of several .jsp files, and I protect it all using the memoryrealm system that asks for the username and password upon entering any of the .jsp pages, and then remembers it for the session, until the browser is closed. My question is, how would I fetch the username of that person so that I could show it to him on one of the pages?

P.s. I am running the webapp on Apache Tomcat 7.0.35

4

1 回答 1

0

// Get username.

String user = request.getRemoteUser();

// Get user principal.

String userPrincipal = request.getUserPrincipal().getName();

// Is user in a specific role? boolean isUserInRole = request.isUserInRole(role);

boolean isUserInJSPRole = request.isUserInRole("jspUser");

From: http://sourceforge.net/apps/trac/ogsa-dai/wiki/FAQHowToPasswordProtectJSPPages

于 2013-09-03T17:16:46.147 回答