You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Doc Digi <sa...@digiatlas.net> on 2004/08/06 17:20:48 UTC

Query regarding serving images

Does Tapestry come with any support for dynamic images? Specifically I have
several thousand pictures that I wish to display based on various search
criteria. The pictures are not all orientated correctly (they are all
landscape) - a database provides the filename of each picture and its
correct orientation. In my stand-alone application I just rotate the
pictures based on the value from the DB. I'd like to do the same in my
Tapestry app - so an href to the image file isn't going to do it as I need
to programatically rotate them.

My limited understanding indicates that this is possible from a servlet by
opening a stream and sending the binary data to the client... but how? And
how can I do it from Tapestry?

Any pointers greatly appreciated!

thanks,
dd




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


Re: Query regarding serving images

Posted by Robert Zeigler <rd...@u.arizona.edu>.
try something along the lines  of:
String basePath = 
cycle.getRequestContext().getServlet().getServletContext().getRealPath("/");
which will return the system path of your webapp root directory.

Robert

Doc Digi wrote:
> Thanks for the info - it was exactly what I needed.
> 
> However, I have one small problem - Tapestry is trying to open the image
> files from C:\winnt\system32 !  I thought it would attempt to get them
> relative to the document root / webapp root...  I'm not very familiar with
> Tomcat & Tapestry (as you can probably tell). Is this something I need to
> tell Tapestry or something I need to set in my config files?
> 
> I've done some fishing around in the docs but I can't seem to find anything
> to really help me.
> 
> dd
> 
> 
> ----- Original Message -----
> From: "Robert Zeigler" <rd...@u.arizona.edu>
> To: "Tapestry users" <ta...@jakarta.apache.org>
> Sent: Friday, August 06, 2004 5:09 PM
> Subject: Re: Query regarding serving images
> 
> 
> 
>>Yes, this can be done in tapestry. The key is to develop a new engine
>>service that will do manipulate the image, and then send the bytes to
>>the client. There have been several good posts dealing with this
>>in the past.
>>cf: http://www.caddr.com/macho/archives/tapestry-users/2004-4/6295.html
>>
>>Robert
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 


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


Re: Query regarding serving images

Posted by Doc Digi <sa...@digiatlas.net>.
Thanks for the info - it was exactly what I needed.

However, I have one small problem - Tapestry is trying to open the image
files from C:\winnt\system32 !  I thought it would attempt to get them
relative to the document root / webapp root...  I'm not very familiar with
Tomcat & Tapestry (as you can probably tell). Is this something I need to
tell Tapestry or something I need to set in my config files?

I've done some fishing around in the docs but I can't seem to find anything
to really help me.

dd


----- Original Message -----
From: "Robert Zeigler" <rd...@u.arizona.edu>
To: "Tapestry users" <ta...@jakarta.apache.org>
Sent: Friday, August 06, 2004 5:09 PM
Subject: Re: Query regarding serving images


> Yes, this can be done in tapestry. The key is to develop a new engine
> service that will do manipulate the image, and then send the bytes to
> the client. There have been several good posts dealing with this
> in the past.
> cf: http://www.caddr.com/macho/archives/tapestry-users/2004-4/6295.html
>
> Robert



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


Re: Query regarding serving images

Posted by Robert Zeigler <rd...@u.arizona.edu>.
Yes, this can be done in tapestry. The key is to develop a new engine 
service that will do manipulate the image, and then send the bytes to 
the client. There have been several good posts dealing with this
in the past.
cf: http://www.caddr.com/macho/archives/tapestry-users/2004-4/6295.html

Robert

Doc Digi wrote:
> Does Tapestry come with any support for dynamic images? Specifically I have
> several thousand pictures that I wish to display based on various search
> criteria. The pictures are not all orientated correctly (they are all
> landscape) - a database provides the filename of each picture and its
> correct orientation. In my stand-alone application I just rotate the
> pictures based on the value from the DB. I'd like to do the same in my
> Tapestry app - so an href to the image file isn't going to do it as I need
> to programatically rotate them.
> 
> My limited understanding indicates that this is possible from a servlet by
> opening a stream and sending the binary data to the client... but how? And
> how can I do it from Tapestry?
> 
> Any pointers greatly appreciated!
> 
> thanks,
> dd
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 


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


Re: Query regarding serving images [auf Viren geprueft]

Posted by Jonathan O'Connor <Jo...@xcom.de>.
DD,
Its fairly easy. We display lots of different types of files with the 
following lines of code:

            HttpServletResponse response = 
cycle.getRequestContext().getResponse();
            response.setContentType(fileDao.getMimeType());
            response.setHeader("Content-Disposition", "inline; 
Filename=\"" + fileDao.getFilename() + "\"");
            ServletOutputStream outStream = response.getOutputStream();
            outStream.write(fileDao.getData());
            outStream.flush();
            outStream.close();

Our fileDao contains a filename, a mimetype (you'll want something like 
"image/jpeg", but you probably already know that), and the raw binary 
data.

Ciao,
Jonathan O'Connor
XCOM Dublin



"Doc Digi" <sa...@digiatlas.net> 
06/08/2004 16:20
Please respond to
"Tapestry users" <ta...@jakarta.apache.org>


To
"Tapestry users" <ta...@jakarta.apache.org>
cc

Subject
Query regarding serving images [auf Viren geprueft]






Does Tapestry come with any support for dynamic images? Specifically I 
have
several thousand pictures that I wish to display based on various search
criteria. The pictures are not all orientated correctly (they are all
landscape) - a database provides the filename of each picture and its
correct orientation. In my stand-alone application I just rotate the
pictures based on the value from the DB. I'd like to do the same in my
Tapestry app - so an href to the image file isn't going to do it as I need
to programatically rotate them.

My limited understanding indicates that this is possible from a servlet by
opening a stream and sending the binary data to the client... but how? And
how can I do it from Tapestry?

Any pointers greatly appreciated!

thanks,
dd




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