It is because the currently executing page already 'owns' the output stream.
The request object knows it and won't give out another handle at the same
time. There are a couple of workarounds, the one I remember is to use a
different output stream (e.g. on a string) and then print the string. I
think there is a way to get the JSP page to relinquish the handle as well,
check out the api docs for HttpServletRequest.

-----Original Message-----
From: Ouyang, Sonny [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, May 08, 2001 5:29 PM
To: JRun-Talk
Subject: IllegalStateException on response.getOutputStream()


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