I just started learning about JSF.
In JSP file we can use <%= request.getAttribute("JsData")%> to get the session data.
How can we get the session data in a Facelets file? For example:
<h:head>
<script type="text/javascript">
//<![CDATA[
var query = jQuery.noConflict();
function getInitData() {
getJSData();
}
//]]>
<%= request.getAttribute("JsData")%>
</script>
</h:head>
<h:body onload="initData();">
<p:commandButton id="loginButton" value="login" ></p:commandButton>
<p:commandButton id="close" value="close" ></p:commandButton>
</h:body>
The JSP scriptlets are indeed fortunately not supported at all in Facelets. Just use EL, like as they introduced over a decade ago in JSP to replace scriptlets.
This kind of data is in JSF normally to be prepared and served by some managed bean. E.g.
Unrelated to the concrete problem, the
request.getAttribute()does not return session scoped data, it returns request scoped data.