[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Tomcat: how to get username
I'm using the usual FORM based login configuration with my Tomcat Webapp, and it works fine. I can even logout by using a link to logout.jsp which contains:
USER logged out of MY WEB APP at <%= new java.util.Date()%>
<% request.getSession(invalidate();%>
This works OK, except I would like to replace USER with the username that was entered in the FORM based (j_username) input by Tomcat. How do I get at the username? session.getAttribute() and servletContext.getAttribute() do not appear to have such attributes as "username" set by Tomcat when the username is entered.
I'm punting, but if anyone knows a simple solution to this, please let me know. I don't see a solution (after an afternoon of researching the net) and this might be a good feature for a future Tomcat release.
Cheers,
Joe
FYI: In web.xml:
<!-- Define a security constraint on this application -->
<security-constraint>
<web-resource-collection>
<web-resource-name>Entire Application</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<!-- This role is not in the default user directory -->
<role-name>manager</role-name>
</auth-constraint>
</security-constraint>
<!-- Define the login configuration for this application -->
<login-config>
<auth-method>FORM</auth-method>
<realm-name>MY WEB APP</realm-name>
</login-config>
<!-- Security roles referenced by this web application -->
<security-role>
<description>
The role that is required to log in to the Manager Application
</description>
<role-name>manager</role-name>
</security-role>
____________________________________________________________
Find what you are looking for with the Lycos Yellow Pages
http://r.lycos.com/r/yp_emailfooter/http://yellowpages.lycos.com/default.asp?SRC=lycos10