title: How to show alert in a jsp from a servlet and then redirect to another jsp?
body: <p><strong>I tried this but does not display the message only redirects</strong>
  <strong>login.jsp</strong></p>
  
  <pre><code>&lt;form method="post" action="Login_Servlet" &gt;
    &lt;input name="idUsuario" type="text"/&gt;
    &lt;input  name="password" type="password" /&gt;
    &lt;button type="submit"&gt;Entrar&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>Login_Servlet</strong></p>
  
  <pre><code>response.setContentType("text/html;charset=UTF-8");
  PrintWriter out = response.getWriter();
  String userid= request.getParameter("idUser");        
  String password = request.getParameter("password");
  Login_Service login_Service = new Login_Service();
  boolean result = login_Servicio.aut(userid, password);
  Usuario user = login_Servicio.getUsuariosByUsuario(userid);
      if(result == true){
         request.getSession().setAttribute("user", user);            
         response.sendRedirect("vistas/Inicio.jsp");
      }
       else{
         out.println("&lt;script type=\"text/javascript\"&gt;");
         out.println("alert('User or password incorrect');");
         out.println("&lt;/script&gt;");
         response.sendRedirect("index.jsp");    
      }
  </code></pre>
  
  <p><strong>Is it possible to display a message like this? if so I'm doing wrong?</strong></p>