title: JSP sendRedirect with return not working
body: <p>First of all, look at my page <a href="https://i.stack.imgur.com/ix9Or.png" rel="nofollow noreferrer">InterFace of My WebSite IMAGE</a></p>
  
  <p>I use file <strong>index.jsp</strong> with parameter <strong>view</strong> (<strong>view</strong> is a path of jsp file I want it to show in <code>&lt;jsp:include&gt;</code> as a iframe. I declare all <strong>view</strong> in an Enum like:</p>
  
  <pre><code>public enum FView {
      HomePage, LogIn, SignUp, Profile, UpdateProfile
  }
  </code></pre>
  
  <p>In my <strong>index.jsp</strong></p>
  
  <pre><code>&lt;%
  String viewParam = request.getParameter("view");
  if (viewParam == null)
      viewParam = "HomePage";
  FView f = FView.valueOf(viewParam);
  
  String pageToView = "";
  switch (f)
  {
      case HomePage:
          pageToView = "page/viewArticles.jsp";
          break;
      case LogIn:
          pageToView = "login.jsp";
          break;
      case Profile:
          pageToView = "page/viewProfile.jsp";
          break;
      default:
          pageToView = "../login.jsp";
          break;
  }%&gt;
  &lt;jsp:include page="main.jsp"&gt;
      &lt;jsp:param name="page" value="&lt;%= pageToView %&gt;
  &lt;/jsp:include&gt;
  </code></pre>
  
  <p>In my <strong>main.jsp</strong></p>
  
  <pre><code>&lt;div id="header"&gt;&lt;/div&gt; &lt;!-- &lt;jsp:include&gt; header here, I don't mention all of it.--&gt;
  &lt;div id="content"&gt;
        &lt;jsp:include page="&lt;%= request.getParameter("page")%&gt;"/&gt; //RED RECTANGLE HERE
  &lt;/div&gt;
  &lt;div id="footer"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>I have a page that shows user's profile <strong>index.jsp?view=Profile</strong> (the path of file is <em>WebContent/page/viewProfile.jsp</em>). I want that when I access to this page without logging in, it will redirect to my login page <strong>index.jsp?view=LogIn</strong> (the path of file is <em>WebContent/login.jsp</em>). Here is the code:</p>
  
  <pre><code>&lt;%  
  Object user_session = session.getAttribute("user_session");;
  
  String usernameFromSession = null;
  if (user_session != null)
      usernameFromSession = user_session.toString();
  else
  {
      response.sendRedirect("index.jsp?view=LogIn");//any url
      return;
  }%&gt;   
  &lt;p&gt;This is the profile page&lt;/p&gt;
  </code></pre>
  
  <p>Knows that <em>usernameFromSession</em> is null. When I reload the page, it shows a white page, nothing even p tag. When I remove <em>return</em>, it shows content (p tag above) of the Profile page.
  But if I use the primitive path: <code>localhost:8088:......./page/viewProfile.jsp</code> instead of <code>localhost:8088:....index.jsp?view=Profile</code>,it worked. So how can I solve it?</p>