tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jay Burgess <>
Subject RE: JSP including servlet output
Date Fri, 17 Jun 2005 21:21:53 GMT
Not a full explanation, but the Javadoc for ServletResponse.getOutputStream()
does say:

java.lang.IllegalStateException - if the getWriter method has been called on
this response

Conversely, getWriter() says:

java.lang.IllegalStateException - if the getOutputStream  method has already
been called for this response object

It'd seem that the Writer had already been acquired.


| Jay Burgess [Vertical Technology Group]
| "Essential Technology Links via RSS"


-----Original Message-----
From: Frank W. Zammetti [] 
Sent: Friday, June 17, 2005 1:21 PM
Subject: Re: JSP including servlet output

Never mind, got it... changed:

ServletOutputStream out = response.getOutputStream();

PrintWriter out = response.getWriter();

...and it now works.  I wouldn't mind an explanation though :)

Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies

On Fri, June 17, 2005 2:02 pm, Frank W. Zammetti said:
> Hey all... I have a situation where I want to use a <jsp:include> whos
> target is actually a servlet... Problem is, in the servlet I do:
> ServletOutputStream out = response.getOutputStream();
> out.println(items.getItem());
> ...which yields:
> java.lang.IllegalStateException
> Commenting out those two lines gets rid of the exception.  If I call the
> servlet directly on its own I get my expected result, so I know the
> servlet itself works.
> I'm assuming this is some sort of limitation of the include mechanism,
> question is, can it be overcome?  I added flush="true" to the include tag,
> which gets rid of the exception but makes the resultant page end where the
> include is, so that's not the answer.
> An ideas?  Is this something that can be done in the first place?  If so,
> how does one overcome this problem?  TIA!
> --
> Frank W. Zammetti
> Founder and Chief Software Architect
> Omnytex Technologies

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message