title: NullPointerException at facesContext.getResponseWriter.write()
body: <p>I am using <code>facesContext.getResponseWriter.write()</code> to display error messages but value of <code>getResponseWriter</code> is <code>null</code>. How to sort out this issue?</p>
  
  <pre><code>if(context != null){ 
      context.getResponseWriter().write(msg) ;
  }
  
  else{
      pageContext.getResponse().getWriter().write(
      "&lt;div id='errorMsgsFromTag' style='position:absolute;visibility:hidden'&gt;" + msg + "&lt;/div&gt;"); 
  }
  </code></pre>
  
  <p>setting message in msg String and getting context by </p>
  
  <pre><code>FacesContext context = FacesContext.getCurrentInstance();
  </code></pre>