title: Struts2 getting request object as null
body: <p>I am facing a strange error in Struts2, I am getting a null pointer exception when trying to set attribute into request scope,</p>
  
  <pre><code>Struts Problem Report
  </code></pre>
  
  <blockquote>
    <p>Struts has detected an unhandled
    exception: Messages:   File:
      org/apache/catalina/connector/Request.java
    Line number:  1,424</p>
  </blockquote>
  
  <pre><code>Stacktraces
  java.lang.NullPointerException
      org.apache.catalina.connector.Request.setAttribute(Request.java:1424)
      org.apache.catalina.connector.RequestFacade.setAttribute(RequestFacade.java:503)
      javax.servlet.ServletRequestWrapper.setAttribute(ServletRequestWrapper.java:284)
      com.inrev.bm.action.IRBrandMgmtAction.wrdTwts(IRBrandMgmtAction.java:81)
      sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      java.lang.reflect.Method.invoke(Unknown Source)
  </code></pre>
  
  <p>My code is given below,</p>
  
  <pre><code>public class IRBrandMgmtAction extends ActionSupport implements SessionAware,ServletRequestAware {
  
  
  private static final long serialVersionUID = 1L;
  
  private Map session;
  
  private HttpServletRequest request; 
  
  private IRWordToTrack wrdtotrack;
  
  private IRBrandMgmtDAO brandMgmtDAO;
  
  private static org.apache.log4j.Logger log = Logger.getLogger(IRBrandMgmtAction.class);
  </code></pre>
  
  <p>and the method where this is happening,</p>
  
  <pre><code>public String wrdTwts()
  {
      ArrayList&lt;IRBrandTrackBean&gt; messages = null;
      IRDateUtil dtUtil = new IRDateUtil();
      String wordId = request.getParameter("wordId");
  
      IRUser user = (IRUser) session.get("user");
      IRWordToTrack word = brandMgmtDAO.getWord(Integer.parseInt(wordId));
  
      if(word!=null)
      {
          messages = brandMgmtDAO.viewMsgForUser(word.getWord().toUpperCase().trim(), null, dtUtil.getTimeZoneOffset(user.getTimeZone()));
      }
  
      request.setAttribute("messages",messages);
  
      return "tweets";
  }
  </code></pre>
  
  <p>I am using tomcat 6 server.</p>
  
  <p>Regards,
  Rohit</p>