title: How to call struts action from doFilter method
body: <p>My <code>struts.xml</code> has two actions as follows</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;action name="dologincheck" class="com.platinum.uac.biz.LoginAction" method="doLogin"&gt;
      &lt;result name="success" type="tiles"&gt;Homepage&lt;/result&gt;
      &lt;!--   &lt;result name="success"&gt;/Profile/view/ViewProfile1.jsp&lt;/result&gt;--&gt;
      &lt;result name="none"&gt;/Profile/add/Failure.jsp&lt;/result&gt;              
      &lt;result name="mail"&gt;/Profile/add/EmailAuthentication.jsp&lt;/result&gt;
  &lt;/action&gt;
  &lt;action name="newuseraction" class="com.platinum.uac.biz.NewUserAction" method="newuser"&gt;
      &lt;result name="success" &gt;/Profile/add/ProfileDetails.jsp&lt;/result&gt;
      &lt;result name="error" &gt;/index.jsp&lt;/result&gt;
  &lt;/action&gt;
  </code></pre>
  
  <p>I need to call an action(<code>dologincheck</code>) from <code>doFilter</code> method. I am stuck here because I do not know how to call an action from <code>doFilter</code> method</p>
  
  <pre class="lang-java prettyprint-override"><code>public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws   
        IOException, ServletException {
      try {
      System.out.println("this is do filter before the jsp page");
      HttpServletRequest request = (HttpServletRequest) req;
      HttpServletResponse response = ((HttpServletResponse) res);
      HttpSession session = request.getSession(true);
      String username, password;
      Cookie[] cookies;
      LoginPojo user = (LoginPojo) session.getAttribute("username");
      if (user == null) {
          cookies = request.getCookies();
          if (cookies != null &amp;&amp; cookies.length &gt; 0) {
              username = getCookieValue(cookies, "username");
              password = getCookieValue(cookies, "password");
              System.out.println(username);
              System.out.println(password);
              if (username != null &amp;&amp; password != null) {
                  LoginPojo pojo = new LoginPojo(username, password);
                  results = dao.Login(pojo);
                   session.setAttribute("userName", user); // usersession?
  
                 request.getRequestDispatcher("dologincheck").forward(request,
                  response);
              } else {
              request.getRequestDispatcher("/index.jsp").forward(request,
              response);
              }
          } else {
          request.getRequestDispatcher("/index.jsp").forward(request,
          response);
          }
      }
      } catch (Exception e) {
      }
      chain.doFilter(req, res);
      //throw new UnsupportedOperationException("Not supported yet.");
  }
  </code></pre>
  
  <p>My Filter part of <code>web.xml</code> is </p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;filter&gt;
      &lt;filter-name&gt;struts2&lt;/filter-name&gt;
      &lt;filter-class&gt;org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter&lt;/filter-class&gt;
  &lt;/filter&gt;
  &lt;filter-mapping&gt;
      &lt;filter-name&gt;struts2&lt;/filter-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
  &lt;/filter-mapping&gt;
  &lt;filter&gt;
      &lt;filter-name&gt;AutomaticLogin&lt;/filter-name&gt;
      &lt;filter-class&gt;com.platinum.uac.biz.AutomaticLogin&lt;/filter-class&gt;
  &lt;/filter&gt;
  &lt;filter-mapping&gt;
      &lt;filter-name&gt;AutomaticLogin&lt;/filter-name&gt;
      &lt;url-pattern&gt;*.jsp&lt;/url-pattern&gt;
      &lt;url-pattern&gt;*.action&lt;/url-pattern&gt;
      &lt;servlet-name&gt;action&lt;/servlet-name&gt;  
      &lt;dispatcher&gt;REQUEST&lt;/dispatcher&gt;
  &lt;/filter-mapping&gt;
  </code></pre>