Re: getOutputStream() has already been called???

From: Ryan Stewart (zzanNOtozz_at_gSPAMo.com)
Date: 03/13/04


Date: Fri, 12 Mar 2004 18:40:08 -0600


"Amy G" <amy-g-art@cox.net> wrote in message
news:_lb4c.22362$BA.13710@fed1read03...
> "Ryan Stewart" <zzanNOtozz@gSPAMo.com> wrote in message
> news:SOSdnbivzvT-3MzdRVn-gg@texas.net...
> > "Amy G" <amy-g-art@cox.net> wrote in message
> > news:%Ua4c.22359$BA.16233@fed1read03...
> > > java.lang.IllegalStateException: getOutputStream() has already been
> called
> > >
> > > This is the error message that is getting attached to the end of the
> > binary
> > > files I am uploading from the server to the enduser. How do I get rid
of
> > > this message? Or redirect it to somewhere other that the OutputStream?
> > >
> > > Following is my code. Any help is greatly appreciated.
> > >
> > > <%@ page language="java"%>
> > > <%@ page import="java.io.*"%>
> > > <%@ page import="java.util.*"%>
> > > <%@ page import="javax.servlet.*"%>
> > > <jsp:useBean id="ppv" class="com.dpcsys.ppv" scope="session"/>
> > > <%
> > *snip*
> > > ServletOutputStream writer =
response.getOutputStream();
> > *snip*
> > > %>
> > >
> >
> > You can only call getOutputStream or getWriter once on a response
object.
> > Your JSP has already done so to create its implicit "out" object. Unless
> I'm
> > mistaken, you can get another output object if you close the existing
one.
> > Aside from that, this code doesn't really belong in a JSP. It belongs in
a
> > servlet.
> >
> >
>
> I understand that it would be better suited for a servlet... however, I
have
> no desire to install jsdk for this one page, when I figure that I can
> accomplish it with a JSP page.
>
> But, how would I go about closing the output object based on my existing
> code.
>
> Thanks for the response.
>
JSPs are translated to servlets before they are compiled. If you can run a
JSP, you can run a servlet. As for closing out: out.close()



Relevant Pages

  • Re: JSP include and servlet
    ... dispatcher.include(request, response); ... In my prelude.jspf I call on a servlet that builds ... I notice that you call it with a relative path in the JSP but an absolute path in the .java servlet. ... When the elements are present, the given paths are automatically included at the beginning and end, respectively, of each JSP page in the property group. ...
    (comp.lang.java.programmer)
  • Re: servlet - output jsp page?
    ... servlet because your servlet is writing "directly" to the response. ... case of a JSP, it gets compiled into a servlet first - and the JSP ...
    (comp.lang.java.programmer)
  • Re: Tomcat Hanging
    ... > appears to hang with the browser waiting for a response. ... > browser and similar jsp, and I could call the servlet but not the jsp. ...
    (comp.lang.java.programmer)
  • Re: getOutputStream() has already been called???
    ... I ended up using the servlet solution. ... But I still had to install JSDK because I am only using JDK 1.3 which does ... A lot more work than using my existing JSP page... ... As for closing out: out.close ...
    (comp.lang.java.programmer)
  • Re: download a file from jsp
    ... the servlet calls to jsp. ... HttpServletResponse response) { ... String strCod_analisis = ...
    (comp.lang.java.programmer)