You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Lev Epshteyn <le...@corsis.com> on 2003/07/16 19:22:00 UTC

RE: Multipart template

You need to generate the image on a separate request.

Inside your template, there should be an <img> tag with a src parameter
referencing your servlet
For example: <IMG SRC="http://www.server.com/webapp/servlet?mode=image">

The servlet should then return an image as a binary stream if it sees the
"mode=image" parameter.

There is no way to output both HTML and an image to the browser on the same
request, as HTML doesn't provide a mechanism to "embed" images in the
document, only to reference them.

-----Original Message-----
From: Jeff Owens [mailto:jeff@payrollnw.com]
Sent: Wednesday, July 16, 2003 1:26 PM
To: Velocity Users List
Subject: Multipart template



Does Velocity provide some way of utilizing a multipart content-type
template?

In other words: I have a servlet generating data for a Velocity template.
Along with text such as name and address, I want a picture to be embedded
within the web page.  HOWEVER, the picture is coming as binary data - NOT a
<img> link or anything like that.

Limitations:
1.  The picture is not stored as a file, it will come from the servlet as
binary data.
2.  The picture must be embedded within a velocity template somehow.
3.  The template I need the picture to go in is already a very nice Velocity
template - I'm not interested in generating the page html myself or
switching to some other templating system.  (I would generate just the
portion of the html for the picture - if I can embed it in the template
somehow)

Thanks for your help,
Jeff Owens



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


Re: Multipart template

Posted by Jeff Owens <je...@payrollnw.com>.
Ah.  I was thinking in a different direction: Content-type:
multipart/mixed;boundary...  something along the lines of O'Reilly's
com.oreilly.servlet.MultipartResponse.

This will work though - excellent!

Thanks Lev!
-jeff


----- Original Message -----
From: "Lev Epshteyn" <le...@corsis.com>
To: "'Velocity Users List'" <ve...@jakarta.apache.org>
Sent: Wednesday, July 16, 2003 10:22 AM
Subject: RE: Multipart template


> You need to generate the image on a separate request.
>
> Inside your template, there should be an <img> tag with a src parameter
> referencing your servlet
> For example: <IMG SRC="http://www.server.com/webapp/servlet?mode=image">
>
> The servlet should then return an image as a binary stream if it sees the
> "mode=image" parameter.
>
> There is no way to output both HTML and an image to the browser on the
same
> request, as HTML doesn't provide a mechanism to "embed" images in the
> document, only to reference them.
>
> -----Original Message-----
> From: Jeff Owens [mailto:jeff@payrollnw.com]
> Sent: Wednesday, July 16, 2003 1:26 PM
> To: Velocity Users List
> Subject: Multipart template
>
>
>
> Does Velocity provide some way of utilizing a multipart content-type
> template?
>
> In other words: I have a servlet generating data for a Velocity template.
> Along with text such as name and address, I want a picture to be embedded
> within the web page.  HOWEVER, the picture is coming as binary data - NOT
a
> <img> link or anything like that.
>
> Limitations:
> 1.  The picture is not stored as a file, it will come from the servlet as
> binary data.
> 2.  The picture must be embedded within a velocity template somehow.
> 3.  The template I need the picture to go in is already a very nice
Velocity
> template - I'm not interested in generating the page html myself or
> switching to some other templating system.  (I would generate just the
> portion of the html for the picture - if I can embed it in the template
> somehow)
>
> Thanks for your help,
> Jeff Owens
>
>
>
> ---------------------------------------------------------------------
> 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: Multipart template

Posted by Tim Colson <tc...@cisco.com>.
Lev wrote:
> There is no way to output both HTML and an image to the 
> browser on the same request, as HTML doesn't provide a mechanism 
> to "embed" images in the
> document, only to reference them.

Yep, that's correct as I understand things. The second-request to get
the servlet generated image should do the trick. 

Just a side note - if the template was producing a multi-part mime EMAIL
(for an HTML capable email client), then the image(s) actually can be
embedded as base64 encoded mime attachements inside one document. 

Cheers,
Timo



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