title: Java Servlet, Send a redirect with html tags
body: <p>I'm looking for a way to send a redirection with my servlet from my first page to a second page adding into the second page a script tag made inside this servlet.</p>
  
  <p>For example:</p>
  
  <pre><code>protected void doGet(HttpServletRequest request, HttpServletResponse response)
          throws ServletException, IOException {
      System.out.println("Received a get request");
      response.getWriter().append("&lt;script&gt;alert(\"I'm here!\")&lt;/script&gt;");
      response.sendRedirect("testRedirect.html");
  }
  </code></pre>
  
  <p>This code doesn't work. How can I fix it?
  Thanks!</p>