SendRedirect() Problem - Opens a New Window

Discussions

Web tier: servlets, JSP, Web frameworks: SendRedirect() Problem - Opens a New Window

  1. SendRedirect() Problem - Opens a New Window (4 messages)

    Hi,

     I am using SendRedirect to redirect to a different
     URL from within a servlet.

     This is the code :

    -----------------------------------------------------------
    public void doGet(HttpServletRequest req, HttpServletResponse res)
    throws ServletException, IOException {
       
        res.setContentType("text/plain");
     
        HttpSession session = req.getSession(true);
        
        String mscode = req.getParameter("mc");
        String murl = req.getParameter("mu");

        Integer mcode = new Integer(mscode);
        session.putValue("clickcode",mcode);
        res.sendRedirect(murl);
        
      }

     
     The Problem is that it opens another browser window.
     I would like it to be in the same window and not open
     anyother one.

     Any ideas / suggestions.

    Thanks
    Anjali
  2. Hi,

    Usually sendRedirect() doesn't open new window.
    I have checked with the following line. It haven't opened new window.
    response.sendRedirect("/servlets/myservlet2");

    try to check what url is being passed.


    goodluck!
  3. Thanks Srinivas,

      I indeed discovered a problem with the URL. It works
      fine now.
     
      I appreciate your help.

    Regards
    Anjali
  4. Can U tell me how you've done to open a new window ?

    Cible
  5. I too needed the same thing. I need to open the new page in a new window. Could you please tell me how you were able to do this?????