title: response.sendRedirect is not working
body: <p>I have two jsps. One is <code>login_first.jsp</code>, another one is <code>main.jsp</code>. After submit in <code>login_first.jsp</code>, I call <code>main.jsp</code>. It works fine. </p>
  
  <p>I have logout button in <code>main.jsp</code> which sends control back to <code>login_first.jsp</code>. it executes <code>login_first.jsp</code> but page is not loading.
  Please help.</p>
  
  <p>login_first.jsp</p>
  
  <pre><code>&lt;%@ page session="false" %&gt;
  &lt;%
  try {   
      HttpSession session = request.getSession(true); 
      if ("Submit".equals(request.getParameter("SubmitButton"))) {                                
          session.setAttribute("userLoggedIn", "true");               
          response.sendRedirect("main.jsp");          
          return;                             
      } else {            
          session.setAttribute("userLoggedIn", "false");              
          session.invalidate();
      }    
  %&gt;                                                                                                 
  &lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"&gt;
  &lt;html&gt;
      &lt;body&gt;      
          &lt;form name="loginForm" method="post"&gt;           
              &lt;table&gt;             
                  &lt;tr&gt;            
                      &lt;td&gt;&lt;input type="submit" name="SubmitButton" value="Submit" class=button/&gt;&lt;/td&gt;
                  &lt;/tr&gt;       
              &lt;/table&gt;                                                    
          &lt;/form&gt;
      &lt;/body&gt; 
  &lt;%
  } catch (Exception e) {
      e.printStackTrace();    
      response.sendRedirect("login_first.jsp");           
      return;
  } 
  %&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>main.jsp</p>
  
  <pre><code>&lt;%@ page session="false" %&gt;
  &lt;%
  try {   
      HttpSession session = request.getSession(false);    
      if (session != null &amp;&amp; "true".equals(session.getAttribute("userLoggedIn"))
              &amp;&amp; !"Logout".equalsIgnoreCase(request.getParameter("logout"))) {        
          // do work          
      } else {        
          if (session != null) {
              session.setAttribute("userLoggedIn", "false");              
          }
          response.sendRedirect("login_first.jsp");           
          return;
      }    
  %&gt;                                                                                                 
  &lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"&gt;
  &lt;html&gt;
      &lt;body&gt;      
          &lt;form name="creditCardForm" target="formresponse" autocomplete="off" method="post"&gt;                 
              &lt;table width="50%" border=0 cellpadding=3 cellspacing=1&gt;            
                  &lt;tr&gt;                    
                      &lt;td&gt;            
                          &lt;div align="right"&gt;                                                                                    
                              &lt;input name="logout" type="submit" class=button value="Logout"&gt;                           
                          &lt;/div&gt;                  
                      &lt;/td&gt;
                  &lt;/tr&gt;               
              &lt;/table&gt;                    
              &lt;iframe name="formresponse" width="0" height="0" style="visibility:hidden"&gt;&lt;/iframe&gt;
          &lt;/form&gt;
      &lt;/body&gt; 
  &lt;%
  } catch (Exception e) {
      e.printStackTrace();
      response.sendRedirect("login_first.jsp");   
      return;
  } 
  %&gt;
  &lt;/html&gt;
  </code></pre>