You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Antony Bourgois <da...@gmail.com> on 2005/11/28 17:32:57 UTC

Image data (from byte array) merging

Hi

I have image data from a byte array I need to populate (append in
fact) into a template.

I've come across iterating thru the data with
#foreach( $i in $array )
$i
#end

... but don't get the result I'd get by appending the binary data
right after the merged template.

I'm using a Spring MVC VelocityView and only want this data array
passed into the context and rendered as binary (no post merge
appending).

How can I handle this?
If a previous post already mentions the solution, I'd appreciate your
passing it on.

Appreciated!

Antony B.

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


Re: Image data (from byte array) merging

Posted by Antony Bourgois <da...@gmail.com>.
Hi Barbara

I'd hoped some velocity tool would handle binary. Oh well.

I've reverted to appending post merged template + binary data to
HttpServletResponse's output stream.  I can still stay within Spring
without using an extra servlet.

Anyway, it works so I'll keep it this way.

Thanks for the prompt response!
Ant

On 28/11/05, Barbara Baughman <ba...@utdallas.edu> wrote:
> Velocity is a templating language and as such only works with strings.
>
> I believe to handle images, you need to have the HTML tag
> <IMG ...>
>
> Within this HTML, you can use Velocity to build the string reference
> to the image.  For example,
> <IMG SRC="${baseurl}/images/myimage.gif">
>
> Otherwise, you could create a servlet that takes some information,
> gets the binary data and serves up the image.  Velocity could help to
> build the URL reference.  For example:
> <IMG SRC="${imageHandlerURL}&user=$userid">
>
> If this is not a web application, then this won't work, but might give
> you some ideas.
>
> Velocity itself changes every reference to a String as it parses, so
> passing binary data to Velocity for interpreation will not be useful.
>
> Barbara Baughman
> X2157
>
> On Mon, 28 Nov 2005, Antony Bourgois wrote:
>
> > Hi
> >
> > I have image data from a byte array I need to populate (append in
> > fact) into a template.
> >
> > I've come across iterating thru the data with
> > #foreach( $i in $array )
> > $i
> > #end
> >
> > ... but don't get the result I'd get by appending the binary data
> > right after the merged template.
> >
> > I'm using a Spring MVC VelocityView and only want this data array
> > passed into the context and rendered as binary (no post merge
> > appending).
> >
> > How can I handle this?
> > If a previous post already mentions the solution, I'd appreciate your
> > passing it on.
> >
> > Appreciated!
> >
> > Antony B.

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


Re: Image data (from byte array) merging

Posted by Will Glass-Husain <wg...@forio.com>.
Good response.  We should put this in the Wiki FAQ.

WILL

----- Original Message ----- 
From: "Barbara Baughman" <ba...@utdallas.edu>
To: "Velocity Users List" <ve...@jakarta.apache.org>
Sent: Monday, November 28, 2005 9:14 AM
Subject: Re: Image data (from byte array) merging


> Velocity is a templating language and as such only works with strings.
> 
> I believe to handle images, you need to have the HTML tag
> <IMG ...>
> 
> Within this HTML, you can use Velocity to build the string reference
> to the image.  For example,
> <IMG SRC="${baseurl}/images/myimage.gif">
> 
> Otherwise, you could create a servlet that takes some information,
> gets the binary data and serves up the image.  Velocity could help to
> build the URL reference.  For example:
> <IMG SRC="${imageHandlerURL}&user=$userid">
> 
> If this is not a web application, then this won't work, but might give
> you some ideas.
> 
> Velocity itself changes every reference to a String as it parses, so
> passing binary data to Velocity for interpreation will not be useful.
> 
> Barbara Baughman
> X2157
> 
> On Mon, 28 Nov 2005, Antony Bourgois wrote:
> 
>> Hi
>>
>> I have image data from a byte array I need to populate (append in
>> fact) into a template.
>>
>> I've come across iterating thru the data with
>> #foreach( $i in $array )
>> $i
>> #end
>>
>> ... but don't get the result I'd get by appending the binary data
>> right after the merged template.
>>
>> I'm using a Spring MVC VelocityView and only want this data array
>> passed into the context and rendered as binary (no post merge
>> appending).
>>
>> How can I handle this?
>> If a previous post already mentions the solution, I'd appreciate your
>> passing it on.
>>
>> Appreciated!
>>
>> Antony B.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>

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


Re: Image data (from byte array) merging

Posted by Barbara Baughman <ba...@utdallas.edu>.
Velocity is a templating language and as such only works with strings.

I believe to handle images, you need to have the HTML tag
<IMG ...>

Within this HTML, you can use Velocity to build the string reference
to the image.  For example,
<IMG SRC="${baseurl}/images/myimage.gif">

Otherwise, you could create a servlet that takes some information,
gets the binary data and serves up the image.  Velocity could help to
build the URL reference.  For example:
<IMG SRC="${imageHandlerURL}&user=$userid">

If this is not a web application, then this won't work, but might give
you some ideas.

Velocity itself changes every reference to a String as it parses, so
passing binary data to Velocity for interpreation will not be useful.

Barbara Baughman
X2157

On Mon, 28 Nov 2005, Antony Bourgois wrote:

> Hi
>
> I have image data from a byte array I need to populate (append in
> fact) into a template.
>
> I've come across iterating thru the data with
> #foreach( $i in $array )
> $i
> #end
>
> ... but don't get the result I'd get by appending the binary data
> right after the merged template.
>
> I'm using a Spring MVC VelocityView and only want this data array
> passed into the context and rendered as binary (no post merge
> appending).
>
> How can I handle this?
> If a previous post already mentions the solution, I'd appreciate your
> passing it on.
>
> Appreciated!
>
> Antony B.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>

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