wutzebaer's answer is right, but it has a problem when then literal variables have any point, for example "person.name"
<script type="text/javascript"> var msg = new Object(); <c:forEach items="#{msg.keySet()}" var="key"> try{
which worked for me, but netbeans shows this error:
Error: The prefix "c" for the "c: forEach" element is not linked.
because he put the insida a script JSTL tag but it works fine however
there is also another way to do this
@ManagedBean(name = "ResouceBundle") @ApplicationScoped public class ResouceBundle implements Serializable { private static final long serialVersionUID = 1L;
and then in XHTML just write:
<script type="text/javascript"> var msg = #{ResouceBundle.msg} </script>
source share