How can I use session for facelets ?
What's the syntax...?
I would put a code like this
<% String loginSession = (String)session.getAttribute("login"); %>
<% i开发者_开发知识库f(loginSession != null){ %>
Welcome <%= session.getAttribute("firstName") %> !
<% }else{ %>
Guest
<% } %>
Thanks
#{sessionScope.login}
You can't have if-s in JSF (you can with JSTL, but it has complications). Instead you can choose to render or not a component:
<h:outputText value="Guest" rendered="#{sessionScope.login != null}" />
精彩评论