HttpServletResponse

S

sridevisd

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
 
A

Andrea Desole

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.
 
S

Steve Sobol

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top