The javadoc for the ServletResponse Interface indicates that you can only 
invoke one of the following methods: getWriter() or getOutputStream() on a 
single ServletResponse object but not both.  If you do then you will get an 
IllegalStateException.

In your JSP page you probably aren't explicitly doing a response.getWriter() 
but I am willing to bet that when the PageContext object creates the 
implicit "out" JspWriter object for you it uses getWriter() behind the 
scenes somewhere.  If so, this would throw the IllegalStateException when 
you do your response.getOutputStream() call.

Just out of curiosity, why are you trying to get the ServletOutputStream to 
write to the response when you could use the implicit "out" object.  I guess 
you could be writing binary data...

Hope this helps - good luck.


>From: "Ouyang, Sonny" <[EMAIL PROTECTED]>
>Reply-To: [EMAIL PROTECTED]
>To: JRun-Talk <[EMAIL PROTECTED]>
>Subject: IllegalStateException on response.getOutputStream()
>Date: Tue, 08 May 2001 17:28:34 -0400
>
>Hi guys,
>
>I try to get a outputStream from the response object in the jsp page but I
>got IllegalStateException. Does anyone know what I did wrong?
>
>Thanks
>
>Sonny
>
>
>jsp page
>------------------------------------------------------------
>
><%@ page import="com.globalspec.util.URL2HTML" %>
><%@ page import="java.io.*" %>
>
><%
>
>out.print("This is a test");
>out.flush();
>OutputStream outStream = response.getOutputStream();
>if (outStream == null)
>{
>       out.print("output stream is null");
>} else
>{
>       URL2HTML.print("http://www.microsoft.com";, outStream);
>}
>%>
>
>----------------------------------------------------
>
>output from the jsp page
>--------------------------------------------------------
>This is a test
>500 Internal Server Error
>/WebScratch/jsp/testURL.jsp:
>
>null
>java.lang.IllegalStateException
>       at
>allaire.jrun.servlet.JRunResponse.getOutputStream(JRunResponse.java:294)
>       at
>jrun__WebScratch__jsp__testURL2ejsp1b._jspService(jrun__WebScratch__jsp__tes
>tURL2ejsp1b.java:48)
>       at allaire.jrun.jsp.HttpJSPServlet.service(HttpJSPServlet.java:40)
>       at allaire.jrun.servlet.JRunSE.service(JRunSE.java:1013)
>       at allaire.jrun.servlet.JRunSE.runServlet(JRunSE.java, Compiled
>Code)
>       at
>allaire.jrun.servlet.JRunNamedDispatcher.forward(JRunNamedDispatcher.java:34
>)
>       at allaire.jrun.jsp.JSPServlet.service(JSPServlet.java:174)
>       at allaire.jrun.servlet.JRunSE.service(JRunSE.java:1013)
>       at allaire.jrun.servlet.JRunSE.runServlet(JRunSE.java, Compiled
>Code)
>       at
>allaire.jrun.servlet.JRunRequestDispatcher.forward(JRunRequestDispatcher.jav
>a:88)
>       at allaire.jrun.servlet.JRunSE.service(JRunSE.java:1131)
>       at allaire.jrun.servlet.JvmContext.dispatch(JvmContext.java:330)
>       at allaire.jrun.jrpp.ProxyEndpoint.run(ProxyEndpoint.java:354)
>       at allaire.jrun.ThreadPool.run(ThreadPool.java, Compiled Code)
>       at allaire.jrun.WorkerThread.run(WorkerThread.java, Compiled Code)
>
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to