title: how to message from servlet and display in jsp
body: <p>I'm trying to do something that looks small but it's failing. I'm trying to send a response message back to a jsp when login fails but not being able. As of now I can only redirect back to the jsp but cannot display a message from the servlet on it. This is the servlet part of the redirection:</p>
  
  <pre><code>                if (count &gt; 0) {
                  res.sendRedirect("adminHome.jsp");
              } else {
  
                  res.sendRedirect("index.jsp");
              }
  </code></pre>
  
  <p>I tried to print a message using PrintWriter and the redirect but failed because I couldn't get how to receive the message in the JSP. I also read that I shouldn't redirect but rather I should just forward from the servlet. How can I do this? Please help with the code patch to forward from servlet as well as that one to receive in JSP. Thanks</p>