Re: Display raw image - given byte[]?

Attila Szegedi <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
As long as the template doesn't write anything else on its own into  
the response writer ('cause it'll use the writer, not output stream),  
I think it would work. I can hardly recommend you do this though - it  
seems highly abusive; you're reaching from a higher level of  
abstraction (view-generating template) to a lower level of abstraction  
(servlet API). If I were you, I'd have a separate Java servlet that  
returns the images, and direct image requests to its URL.

Attila.

--
home: http://www.szegedi.org
twitter: http://twitter.com/szegedi
weblog: http://constc.blogspot.com

On 2009.10.14., at 2:10, Mathew Rowley wrote:

> I came across this tutorial:
>
> http://www.conandalton.net/2008/10/sending-binary-data-from-freemarker.html
>
> It uses freemarker to call a method that writes to the default  
> stream.  Is there any security ramification to have the template  
> being able to access the HttpServletRespones object? Are there any  
> other issues with doing as the tutorial describes?  Thanks.
>
> MAT
>
>
> On 10/13/09 2:44 PM, "Daniel Dekany" <[email protected]> wrote:
>
>> Tuesday, October 13, 2009, 9:29:47 PM, Mathew Rowley wrote:
>>
>> > I have an interface that returns an image in the form ‘byte[]’.  Is
>> > it possible to create a ftl that “writes” that image out to the  
>> user
>> > – setting the header to image/png, etc?  Thanks.
>>
>> Nope... FreeMarker has no control over the MIME-type or over the
>> output charset (which should be ISO-8859-1 if you want to keep the
>> bits); the embedding framework has. Even then, it would be quite
>> inefficient due to FreeMarker uses 16 bit char-s (UNICODE)  
>> internally.
>> Last not least, it would be a miss-use of FreeMarker.
>>
>> > MAT
>> --
>> Best regards,
>>  Daniel Dekany

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.