You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Frank W. Zammetti" <fz...@omnytex.com> on 2005/06/17 20:02:01 UTC

JSP including servlet output

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
org.apache.jasper.runtime.ServletResponseWrapperInclude.getOutputStream(ServletResponseWrapperInclude.java:62)

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
http://www.omnytex.com

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: JSP including servlet output

Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
Never mind, got it... changed:

ServletOutputStream out = response.getOutputStream();

..to...

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
http://www.omnytex.com

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
> org.apache.jasper.runtime.ServletResponseWrapperInclude.getOutputStream(ServletResponseWrapperInclude.java:62)
>
> 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
> http://www.omnytex.com
>


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org