HttpServletResponse

Discussion in 'Java' started by sridevisd@gmail.com, Dec 8, 2004.

  1. Guest

    I am trying to do a
    response.sendRedirect("http://"+"/servlet/MyServlet");

    I get an error:
    java.io.IOException: Response has been closed

    I try to do the same in a different servlet it works.
    Could anyone tell me why I get this error.

    Thanks in advance
    Sridevi
    , Dec 8, 2004
    #1
    1. Advertising

  2. It looks like the response writer has been closed.
    You should also check that the response has not been committed, as
    defined in the HttpServletResponse documentation.

    wrote:
    > I am trying to do a
    > response.sendRedirect("http://"+"/servlet/MyServlet");
    >
    > I get an error:
    > java.io.IOException: Response has been closed
    >
    > I try to do the same in a different servlet it works.
    > Could anyone tell me why I get this error.
    >
    > Thanks in advance
    > Sridevi
    >
    Andrea Desole, Dec 8, 2004
    #2
    1. Advertising

  3. Steve Sobol Guest

    wrote:
    > I am trying to do a
    > response.sendRedirect("http://"+"/servlet/MyServlet");
    >
    > I get an error:
    > java.io.IOException: Response has been closed


    Well, that is probably because you're trying to redirect to the URL

    http:///servlet/MyServlet

    That doesn't work.

    If /servlet/MyServlet is served at the same hostname as the page you're
    redirecting from, for example if you're redirecting from
    http://abc.def.org/some.jsp to http://abc.def.org/servlet/MyServlet, then you
    can do this:

    response.sendRedirect("/servlet/MyServlet")

    otherwise you need to include the full URL.

    --
    JustThe.net Internet & New Media Services, http://JustThe.net/
    Steven J. Sobol, Geek In Charge / 888.480.4NET (4638) /
    PGP Key available from your friendly local key server (0xE3AE35ED)
    Apple Valley, California Nothing scares me anymore. I have three kids.
    Steve Sobol, Dec 8, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mike Landis

    HttpServletResponse.sendError

    Mike Landis, Aug 8, 2003, in forum: Java
    Replies:
    1
    Views:
    4,357
    Dave Miller
    Aug 9, 2003
  2. Joerg Mueller-Tolk
    Replies:
    2
    Views:
    996
    Joerg Mueller-Tolk
    Dec 3, 2003
  3. Naresh Agarwal
    Replies:
    0
    Views:
    409
    Naresh Agarwal
    May 28, 2004
  4. Naresh Agarwal
    Replies:
    1
    Views:
    1,034
    ExGuardianReader
    May 29, 2004
  5. Tim
    Replies:
    0
    Views:
    622
Loading...

Share This Page