Hi Evan,

> My name is Evan Leonard. This is my first post to the users group, so I'd
> like to start by saying, great work with velocity. I am enjoying working
> with it very much. Simple & powerful, excellent.

Welcome to the gang!  :)

> I am mainly using velocity in a struts/servlet situation, but I'd like a
> more general answer that would work in other environments as well. My
> question has to do with writing directly to the output stream that the
> velocity engine is using, mid-template.   For instance if I have a template
> that looks like:
> 
> ...[some html]...
> 
> $RefenceToAnObjectWithAStream.streamToOutput($ReferenceToOutputStream)
> 
> ...[some more html]...
> 
> I'm not sure what output stream to pass to the streaming function. I've
> tried using $response.getOutputStream and $response.getWriter from within
> the template.  I've tried making a velocity view tool that grabs the
> response in its init method and holds on to it until the tool is used. But
> these methods all create very unusual results, like outputing things in the
> wrong order, or not outputing some things at all.
> 
> So my question is, how do I get ahold of the actual stream that the velocity
> engine is using, from within a template, and add my own output to it? Is
> this possible, or is there a better way?

You can't.  Also, Velocity outputs to Writers, not Streams.

I'm not sure what exactly you're trying to do, but some suggestions:
- Put a String representation of the Stream in the Context and render it.
- Create a $RefenceToAnObjectWithAStream.streamToString() method and call it.
- Create a tool that converts a Stream to a String and call it.
- Put a StringWriter wrapped in an OutputStreamWriter in the Context
and render it after calling your
$RefenceToAnObjectWithAStream.streamToOutput() method.

Best regards,
-- Shinobu

--
Shinobu Kawai <[EMAIL PROTECTED]>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to