IllegalStateException (Tomcat, Servlet include)

D

Duane Morin

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
 
D

Duane Morin

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
 
J

John C. Bollinger

Duane said:
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
(e-mail address removed)
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top