tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jay Burgess <li...@vtgroup.com>
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:

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

Conversely, getWriter() says:

Throws:
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

| Jay Burgess [Vertical Technology Group]
| "Essential Technology Links via RSS"
| http://www.vtgroup.com/



 

-----Original Message-----
From: Frank W. Zammetti [mailto:fzlists@omnytex.com] 
Sent: Friday, June 17, 2005 1:21 PM
To: tomcat-user@jakarta.apache.org
Subject: Re: JSP including servlet output

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




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


Mime
View raw message