Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Form based JAAS, using JSTL: how to check in JSP if user is logged in?  RSS feed

 
Vladimir Razov
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using form based, declarative security approach. And, when some user, on login form enters user credentials (username and password), he is being redirected to certain/secured jsp page. Part of that page content is:

You can see that this is implemented using JSP scriptlet. And this works. I would like to use JSTL instead of scriptlet. So, instead of scriptlet, I put this JSTL code: <c:out value="${requestScope.userPrincipal.name}"/>, but not getting user's username with it.
Basically, I don't clearly understand where and how are these objects/user credentials being stored with Form based JAAS.

And, as stated in subject question, I would like on JSP page to check if some user is already logged in. So, if there is logged user to display user's name (also with JSTL).
Something like this:

Here I tried with sessionScope but still not getting anything.
 
Vladimir Razov
Ranch Hand
Posts: 42
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was missing pageContext object , request by itself is not implicit object in JSP page.


And JSTL equivalent for <%=request.getUserPrincipal().getName().toString()%> is: <c:out value="${pageContext.request.userPrincipal.name}"/>
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66184
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for posting back with your findings.
 
Vladimir Razov
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!