title: How can i open a window popup in Servlet and then Redirect a Page
body: <p>I want to open a popup window on calling a servlet and then want to redirect servlet to some <code>.jsp</code> page.</p>
  
  <p>This is what i've done:</p>
  
  <pre><code>protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
          // TODO Auto-generated method stub
          PrintWriter out = response.getWriter();
          out.println("&lt;html&gt;&lt;body&gt;");
          out.println("&lt;script type=\"text/javascript\"&gt;");
          out.println("window.open(\"pageA.jsp\")");
          out.println("&lt;/script&gt;");
          out.println("&lt;/body&gt;&lt;/html&gt;");
          response.sendRedirect("pageB.jsp");
      }
  </code></pre>
  
  <p>This code will only popup window when the <code>response.sendRedirect("error.jsp");</code> is not present or commented. Currently with this code, it is not popping a window and directly redirecting this page to <code>error.jsp</code></p>
  
  <p>How can i do both of the above things at the same time?</p>