IllegalStateException (Tomcat, Servlet include)

Discussion in 'Java' started by Duane Morin, Jul 24, 2003.

  1. Duane Morin

    Duane Morin Guest

    I've got a Servlet that writes to response.outputstream. I have a JSP
    page that I want to include that servlet: <jsp:include page="/foo" />

    But I get an IllegalStateException. The stack trace verifies that my
    servlet is being called, because the exception is thrown the first
    time I try to write to the output stream.

    What am I doing that's illegal? Evreything I've read on the include
    API says that it is for including servlets, JSP or HTML.

    Duane
     
    Duane Morin, Jul 24, 2003
    #1
    1. Advertising

  2. Duane Morin

    Duane Morin Guest

    Never mind, answered my own question. There is both a getOutputStream()
    and a getWriter() on ServletResponse, and once you use one you can't
    use the other. I don't explicitly use the writer anyplace, but I'm
    going to assume that Jasper does. When I switched from outputStream
    to writer, it works fine.

    Duane

    In article <>,
    Duane Morin <> wrote:
    >I've got a Servlet that writes to response.outputstream. I have a JSP
    >page that I want to include that servlet: <jsp:include page="/foo" />
    >
    >But I get an IllegalStateException. The stack trace verifies that my
    >servlet is being called, because the exception is thrown the first
    >time I try to write to the output stream.
    >
    >What am I doing that's illegal? Evreything I've read on the include
    >API says that it is for including servlets, JSP or HTML.
    >
    >Duane
     
    Duane Morin, Jul 24, 2003
    #2
    1. Advertising

  3. Duane Morin wrote:
    > Never mind, answered my own question. There is both a getOutputStream()
    > and a getWriter() on ServletResponse, and once you use one you can't
    > use the other. I don't explicitly use the writer anyplace, but I'm
    > going to assume that Jasper does. When I switched from outputStream
    > to writer, it works fine.


    You are correct. The implicit "out" object provided in JSPs is the
    Writer, and that is the object with which template text is written. If
    your servlet is outputting text then the Writer is probably what it
    should have been using all along anyway.


    John Bollinger
     
    John C. Bollinger, Jul 24, 2003
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kim Ray
    Replies:
    1
    Views:
    1,937
    Ryan Stewart
    Feb 18, 2004
  2. Kim Ray
    Replies:
    3
    Views:
    2,374
    Tony Morris
    Feb 19, 2004
  3. circuit_breaker
    Replies:
    2
    Views:
    2,052
    Jack Jia
    Apr 4, 2004
  4. Replies:
    9
    Views:
    30,377
    sameer.rede
    Sep 4, 2007
  5. javadev
    Replies:
    5
    Views:
    13,004
    javadev
    Nov 16, 2006
Loading...

Share This Page