glassfish - How can I get j_username on my index.jsp after successful authentication with j_security_check? -
i'm using j_security_check on login.jsp. server glassfish server 3. works, when user authenticated opens index.jsp. problem need j_username in index.jsp, couldn't find way of doing it. solutions found in java , need works jsp.
any ideas? thank in advance!
the involved request in jsp el available pagecontext#getrequest()
. logged-in user available httpservletrequest#getuserprincipal()
. username in turn available principal#getname()
.
so,
<p>welcome, <c:out value="${pagecontext.request.userprincipal.name}" /></p>
should do.
using <c:out>
way not necessary, useful case username contain special html characters malform html output <
, >
, "
, on (which source xss attacks). <c:out>
escapes them displayed literally instead of being interpreted part of html markup.
Comments
Post a Comment