Error getWriter() was already called in downloading

if i will use window.open it works fine. But when ii want to use request dispather or call new class method i am getting this

error. The thing is that before downloading starts i am using resonse for writing some HTML content after finishing that it should start

downloding. If use out.close() before download method then it is not calling downlaod method but writing html content. Strange same things works

fine in window.open WHY?.

Error. The server encountered an unexpected condition which prevented it from fulfilling the request.

java.lang.IllegalStateException: getWriter() was already called

at java.lang.Throwable.fillInStackTrace(Native Method)

at java.lang.Throwable.(Throwable.java:94)

at java.lang.Exception.(Exception.java:42)

at java.lang.RuntimeException.(RuntimeException.java:47)

at java.lang.IllegalStateException.(IllegalStateException.java:45)

at newatlanta.servletexec.Response.getOutputStream(Response.java)

at DownloadClass.DownloadForm(DownloadClass.java:23)

at MainServlet.uploadForm(MainServlet.java:1094)

at MainServlet.checkOut(MainServlet.java:421)

at MainServlet.doGet(MainServlet.java:112)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:715)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:840)

at newatlanta.servletexec.ServletExec.processServletRequest(ServletExec.java)

at newatlanta.servletexec.ServletExec.ProcessRequest(ServletExec.java)

at newatlanta.servletexec.ServletExec.ProcessRequest(ServletExec.java)

[1613 byte] By [priviet] at [2007-9-26 2:21:19]
# 1

hi,

i suspect you are using the requestdispatcher forward method. when this method is called, no output should have been sent to the client. even the response.getWriter() method must not have been called.

write the code using the if condition so that you do the forward in one portion where there is no need to send the output.

regards

srini

vams00 at 2007-6-29 9:26:19 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
But i have to write some HTML content then only forward (redirect ) the request to some other class or servlet.The problem is that even i am putting this in if condition it is not executing html part directly going to download function
priviet at 2007-6-29 9:26:19 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
Try using the RequestDispatcher include method , we had the same problem and include solved it the only thing which u cannot do is set the content type to something else before calling the include method.
TalwarR at 2007-6-29 9:26:19 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
Thanks i found another solution
priviet at 2007-6-29 9:26:19 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...