You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by "Payne, Matthew" <pa...@Telerx.com> on 2003/10/02 16:27:52 UTC

Please consider this change (from user list)

Modify the mergeTemplate() method of the VelocityViewServlet 
To use 
PrintWriter pw = response.getWriter(); 

And use the PrintWriter instead of the ServletOutputStream.

Refer to:
http://www.mail-archive.com/tomcat-user@jakarta.apache.org/msg41885.html


In short -----------------------------------------------------------

you can't call response.getOutputStream() if something else called 
response.getWriter() in the same request.

You will get an IllegalStateExeption.

jsp calls response.getWriter(), lets be compatible with them

----------------------------------------------------------

Why---> 
This appears to work very well.  I tested this on tomcat and resin.

By using response.getWriter(), this simple change would make the
VelocityServlet "more" compatible with jsp. This should enabled velocity to
be have better interchangeability with tiles/jsp.
Mixed tiles definitions like this will work fine.   

 <definition name="jsplayout"
 	            path="/layout.jsp">
>> 		<put name="header"
>> 		     value="/header.vm"/>
>> 		<put name="footer"
>> 		     value="/footer.jsp"/>
>> 		<put name="body"
>> 		     value="/center/listThemes.vm"/>
>> 		<put name="rail"
>> 		     value="/rail.jsp"/>
>> </definition>

Here is the message from the user list.

http://www.mail-archive.com/velocity-user@jakarta.apache.org/msg10683.html

Note though, this change will not completely help the opposite, where a
definition is based on a velocity layout.

i.e.

 <definition name="vmlayout"
 	            path="/layout.vm">
>> 		<put name="header"
>> 		     value="/header.vm"/>
>> 		<put name="footer"
>> 		     value="/footer.jsp"/>
>> 		<put name="body"
>> 		     value="/center/listThemes.vm"/>
>> 		<put name="rail"
>> 		     value="/rail.jsp"/>
>> </definition>

In order for that to work, it would require an additional change to the
tiles tool.  I know what needs to be done, but holding that for another
discussion.


Matthew Payne


Re: Please consider this change (from user list)

Posted by "Daniel L. Rall" <dl...@finemaltcoding.com>.
Matthew, this is an excellent suggestion.  Would you file an issue in 
Bugzilla?  If you're feeling especially uppity, try your hand at a quick patch 
to the xdocs and attach it to your issue.

- Dan

Payne, Matthew wrote:
> Modify the mergeTemplate() method of the VelocityViewServlet 
> To use 
> PrintWriter pw = response.getWriter(); 
> 
> And use the PrintWriter instead of the ServletOutputStream.
> 
> Refer to:
> http://www.mail-archive.com/tomcat-user@jakarta.apache.org/msg41885.html
> 
> 
> In short -----------------------------------------------------------
> 
> you can't call response.getOutputStream() if something else called 
> response.getWriter() in the same request.
> 
> You will get an IllegalStateExeption.
> 
> jsp calls response.getWriter(), lets be compatible with them
> 
> ----------------------------------------------------------
> 
> Why---> 
> This appears to work very well.  I tested this on tomcat and resin.
> 
> By using response.getWriter(), this simple change would make the
> VelocityServlet "more" compatible with jsp. This should enabled velocity to
> be have better interchangeability with tiles/jsp.
> Mixed tiles definitions like this will work fine.   
> 
>  <definition name="jsplayout"
>  	            path="/layout.jsp">
> 
>>>		<put name="header"
>>>		     value="/header.vm"/>
>>>		<put name="footer"
>>>		     value="/footer.jsp"/>
>>>		<put name="body"
>>>		     value="/center/listThemes.vm"/>
>>>		<put name="rail"
>>>		     value="/rail.jsp"/>
>>></definition>
> 
> 
> Here is the message from the user list.
> 
> http://www.mail-archive.com/velocity-user@jakarta.apache.org/msg10683.html
> 
> Note though, this change will not completely help the opposite, where a
> definition is based on a velocity layout.
> 
> i.e.
> 
>  <definition name="vmlayout"
>  	            path="/layout.vm">
> 
>>>		<put name="header"
>>>		     value="/header.vm"/>
>>>		<put name="footer"
>>>		     value="/footer.jsp"/>
>>>		<put name="body"
>>>		     value="/center/listThemes.vm"/>
>>>		<put name="rail"
>>>		     value="/rail.jsp"/>
>>></definition>
> 
> 
> In order for that to work, it would require an additional change to the
> tiles tool.  I know what needs to be done, but holding that for another
> discussion.



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