title: How to put data in view scope via EL in JSF page
body: <p>In my JSF page this works:</p>
  
  <pre><code>${requestScope.put('test', 'data')}
  ${requestScope.get('test')}
  </code></pre>
  
  <p>This causes exception:</p>
  
  <pre><code>${viewScope.put('test', 'data')}
  ${viewScope.get('test')}
  </code></pre>
  
  <p>Exception:</p>
  
  <pre><code>java.lang.NullPointerException
      javax.el.BeanELResolver.invoke(BeanELResolver.java:159)
      javax.el.CompositeELResolver.invoke(CompositeELResolver.java:84)
      org.apache.el.parser.AstValue.getValue(AstValue.java:157)
      org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:184)
      com.sun.faces.facelets.el.ELText$ELTextVariable.writeText(ELText.java:238)
      com.sun.faces.facelets.el.ELText$ELTextComposite.writeText(ELText.java:154)
      com.sun.faces.facelets.compiler.TextInstruction.write(TextInstruction.java:85)
      com.sun.faces.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:82)
      com.sun.faces.facelets.compiler.UILeaf.encodeAll(UILeaf.java:183)
      javax.faces.render.Renderer.encodeChildren(Renderer.java:176)
      javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:889)
      javax.faces.component.UIComponent.encodeAll(UIComponent.java:1856)
      javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
      com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:456)
      com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:133)
      com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)
      com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
      com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)
      javax.faces.webapp.FacesServlet.service(FacesServlet.java:647)
      org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
  </code></pre>
  
  <p>How do I use other than <code>requestScope</code> on JSF page? I can of course have a view scoped bean but I thought I can use the scope variables directly. I have Tomcat 8.0.21 with Mojarra 2.2.10.</p>