You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Alain Van Vyve <Al...@brussels.sema.slb.com> on 2004/01/15 15:34:49 UTC

accessing an image outside my webapp

I have a JSP where I would like to show an image located outside my webapp 
(e.g. in a c:\photo directory)  ...

How to do that with the <html:img> Struts tag ??

Thanks

Alain


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


Re: accessing an image outside my webapp

Posted by Mark Lowe <ma...@talk21.com>.
You'll probably want an action that gets the image and then streams it 
to the html:img tag or c:url

<html:img page="/image.do" />

This way you wont be confined to the webapp.

e.g

response.setContentType("image/jpeg");
response.setHeader("Cache-Control", "no-cache");

OutputStream ou = response.getOutputStream();

String imageStr = "/path to image";
java.net.URI imgUri = new java.net.URI(imageStr);
File imageFile = new File(imgUri);
RandomAccessFile raf = new RandomAccessFile( imageFile, "r" );
FileInputStream imageFileStream = new FileInputStream(imageFile);
byte[] image = new byte[(int) imageFile.length()];

while ( (raf.read( image )) > 0 ){
		ou.write( image );
}

ou.flush();
ou.close();
return null;

map the action

<action path="/image" type="com.sparrow.struts.ImageAction" />



On 15 Jan 2004, at 14:34, Alain Van Vyve wrote:

>
> I have a JSP where I would like to show an image located outside my 
> webapp (e.g. in a c:\photo directory)  ...
>
> How to do that with the <html:img> Struts tag ??
>
> Thanks
>
> Alain
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>


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


RE: accessing an image outside my webapp

Posted by Michael McGrady <mi...@michaelmcgrady.com>.
You can do this so long as the parameter expects an output stream of some 
sort.  How that stream gets there is of no consequence, so long as whatever 
you use as the "src" etc. is sufficient to tell the server what to send 
back.  You can give a standard server URL and trust in the server to 
provide what the client needs or you can use something like: 
GetResource.do?file_type=gif&file_name=some.gif with the appropriate class 
to get an output stream from the response object and return the data with 
the correct content type.  I only return data this way, except with 
Applets, which are all screwed up.  That way the organization of resources 
on the server is completely dark to the view, except for Applets, which are 
all screwed up.  (Applets bifurcate the file and codebase names, making 
sensible organization impossible.  Anyone interested in this solution is 
invited to ask for it from me.

At 07:25 AM 1/15/2004, Robert Nocera wrote:
>I don't think Tomcat does, but your local browser will.  You are sending
>your browser a link that tells it to load a file on your file system.  It
>will work fine if you are only running locally, but it won't work if you try
>to access that link from a browser on another machine unless that machine
>also has the same file locally.
>
>-Rob
>
>-----Original Message-----
>From: Mark Lowe [mailto:mark.lowe@talk21.com]
>Sent: Thursday, January 15, 2004 10:14 AM
>To: Struts Users Mailing List
>Subject: Re: accessing an image outside my webapp
>
>by jingo. it only works!!
>
>just src rather than href
>
>I thought tomcat wouldn't have access to anything outside the webapp. On 
>15 Jan 2004, at 15:03, Richard Hightower wrote: > seems like an odd 
>request... but here goes... > > > > html:img supports three attributes for 
>specifyin the location of an > image > forward (referes to a global 
>forward), page (relative to the current > web > context), and href (any 
>valid URL). > > Rick Hightower > Developer > > Struts/J2EE training -- 
>http://www.arc-mind.com/strutsCourse.htm > > Struts/J2EE consulting -- > 
>http://www.arc-mind.com/consulting.htm#StrutsMentoring > > -----Original 
>Message----- > From: Alain Van Vyve 
>[mailto:Alain.VanVyve@brussels.sema.slb.com] > Sent: Thursday, January 15, 
>2004 7:35 AM > To: struts-user@jakarta.apache.org > Subject: accessing an 
>image outside my webapp > > > > I have a JSP where I would like to show an 
>image located outside my > webapp > (e.g. in a c:\photo directory) ... > > 
>How to do that with the Struts tag ?? > > Thanks > > Alain > > > 
>--------------------------------------------------------------------- > To 
>unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org > For 
>additional commands, e-mail: struts-user-help@jakarta.apache.org > > > 
>--------------------------------------------------------------------- > To 
>unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org > For 
>additional commands, e-mail: struts-user-help@jakarta.apache.org > 
>--------------------------------------------------------------------- To 
>unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org For 
>additional commands, e-mail: struts-user-help@jakarta.apache.org 
>--------------------------------------------------------------------- To 
>unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org For 
>additional commands, e-mail: struts-user-help@jakarta.apache.org



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


Re: accessing an image outside my webapp

Posted by Michael McGrady <mi...@michaelmcgrady.com>.
Actually, this does not require that the page be JSP.  This solution works 
with HTML just as well.  So long as you have some mechanism for notifying 
the server that the request should go to a controller, then HTML and JSP 
work the same.  The controller, not the page handles the Java, so the page 
need not be Java smart.

At 09:01 AM 1/15/2004, you wrote:
>??
>I'm not sure what you mean, you don't forward with this action just return 
>null. You can pass what you need as parameters, I just gave you an example 
>with the perhaps naive expectation that you might work the rest out.
>
>
>On 15 Jan 2004, at 16:42, Alain Van Vyve wrote:
>
>>that assumes you are not working with jsp anymore for that page ...
>>I cannot do that because my page contains a lot of other things ...
>>
>>Do you think it is possible to integrate that code in my jsp page ?
>>
>>
>>At 15:59 15/01/2004 +0000, you wrote:
>>
>>Have an action that write the image to the response
>>
>>
>>response.setContentType("image/jpeg");
>>response.setHeader("Cache-Control", "no-cache");
>>
>>OutputStream ou = response.getOutputStream();
>>
>>String imageStr = "/path to image";
>>java.net.URI imgUri = new java.net.URI(imageStr);
>>File imageFile = new File(imgUri);
>>RandomAccessFile raf = new RandomAccessFile( imageFile, "r" );
>>FileInputStream imageFileStream = new FileInputStream(imageFile);
>>byte[] image = new byte[(int) imageFile.length()];
>>
>>while ( (raf.read( image )) > 0 ){
>>                 ou.write( image );
>>}
>>
>>ou.flush();
>>ou.close();
>>return null;
>>
>>//map the action
>>
>><action path="/image" type="com.sparrow.struts.ImageAction" />
>>
>>
>>//
>>
>>call the action
>>
>>On 15 Jan 2004, at 15:45, Alain Van Vyve wrote: > I think It is an 
>>intersting debate about relative versus absolute > addressing ... > but 
>>I'm not relatively but absolutely lost ... > Here is my jsp source ... > 
>>What do I have to change ? > > 
>>Thanks > > ><image.tiff>name="HotelListForm" > property='<%= 
>>"hotelList.hotel[" + i + > "].urlPhoto" %>' />' > alt=' 
>>name="HotelListForm" > property='<%= "hotelList.hotel[" + i + > 
>>"].urlPhoto" %>' />' > border=0 > > > > > > At 15:44 15/01/2004 +0000, 
>>you wrote: >> I think robert it right, i've just tested it too. And i 
>>don't think >> that anyone is confused between absolute and relative 
>>addressing. >> >>http://www.peevish.co.uk/slang/c.htm>> >> see chocolate 
>>fireguard >> >> >> >> On 15 Jan 2004, at 15:28, Martin Gainty 
>>wrote: >> >>> Robert >>> The client browser is making a request to a 
>>webserver using a >>> "relative >>> address" I think it would be best to 
>>understand the difference >>> between >>> "relative addressing" and 
>>"absolute addressing" >>> I invite you to 
>>read >>>http://www.drizzle.com/~slmndr/tutorial/relabs.html>>> 
>>-Martin >>> ----- Original Message ----- >>> From: "Robert Nocera" >>> 
>>To: "'Struts Users Mailing List'" >>> Sent: Thursday, January 15, 2004 
>>10:25 AM >>> Subject: RE: accessing an image outside my 
>>webapp >>> >>> >>>> I don't think Tomcat does, but your local browser 
>>will. You are >>>> sending >>>> your browser a link that tells it to load 
>>a file on your file >>>> system. It >>>> will work fine if you are only 
>>running locally, but it won't work >>>> if you >>> try >>>> to access 
>>that link from a browser on another machine unless that >>>> machine >>>> 
>>also has the same file locally. >>>> >>>> -Rob >>>> >>>> -----Original 
>>Message----- >>>> From: Mark Lowe [mailto:mark.lowe@talk21.com] >>>> 
>>Sent: Thursday, January 15, 2004 10:14 AM >>>> To: Struts Users Mailing 
>>List >>>> Subject: Re: accessing an image outside my webapp >>>> >>>> by 
>>jingo. it only works!! >>>> >>>> just src rather than 
>>href >>>> >>>> >>>> >>>> I thought tomcat wouldn't have access to 
>>anything outside the >>>> webapp. >>>> >>>> >>>> On 15 Jan 2004, at 
>>15:03, Richard Hightower wrote: >>>> >>>>> seems like an odd request... 
>>but here goes... >>>>> >>>>> >>>>> >>>>> html:img supports three 
>>attributes for specifyin the location of an >>>>> image >>>>> forward 
>>(referes to a global forward), page (relative to the >>>>> current >>>>> 
>>web >>>>> context), and href (any valid URL). >>>>> >>>>> Rick 
>>Hightower >>>>> Developer >>>>> >>>>> Struts/J2EE training 
>>--http://www.arc-mind.com/strutsCourse.htm>>>>> >>>>> Struts/J2EE 
>>consulting 
>>-- >>>>>http://www.arc-mind.com/consulting.htm#StrutsMentoring>>>>> >>>>> 
>>-----Original Message----- >>>>> From: Alain Van Vyve 
>>[mailto:Alain.VanVyve@brussels.sema.slb.com] >>>>> Sent: Thursday, 
>>January 15, 2004 7:35 AM >>>>> To: struts-user@jakarta.apache.org >>>>> 
>>Subject: accessing an image outside my webapp >>>>> >>>>> >>>>> >>>>> I 
>>have a JSP where I would like to show an image located outside my >>>>> 
>>webapp >>>>> (e.g. in a c:\photo directory) ... >>>>> >>>>> How to do 
>>that with the Struts tag ?? >>>>> >>>>> Thanks >>>>> >>>>> 
>>Alain >>>>> >>>>> >>>>> 
>>------------------------------------------------------------------- >>>>> 
>>-- >>>>> To unsubscribe, e-mail: 
>>struts-user-unsubscribe@jakarta.apache.org >>>>> For additional commands, 
>>e-mail: >>>>> struts-user-help@jakarta.apache.org >>>>> >>>>> >>>>> 
>>------------------------------------------------------------------- >>>>> 
>>-- >>>>> To unsubscribe, e-mail: 
>>struts-user-unsubscribe@jakarta.apache.org >>>>> For additional commands, 
>>e-mail: >>>>> struts-user-help@jakarta.apache.org >>>> >>>> >>>> 
>>-------------------------------------------------------------------- >>>> 
>>- >>>> To unsubscribe, e-mail: 
>>struts-user-unsubscribe@jakarta.apache.org >>>> For additional commands, 
>>e-mail: struts-user-help@jakarta.apache.org >>>> >>>> >>>> 
>>-------------------------------------------------------------------- >>>> 
>>- >>>> To unsubscribe, e-mail: 
>>struts-user-unsubscribe@jakarta.apache.org >>>> For additional commands, 
>>e-mail: struts-user-help@jakarta.apache.org >>>> >>> >>> 
>>--------------------------------------------------------------------- >>> 
>>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org >>> 
>>For additional commands, e-mail: 
>>struts-user-help@jakarta.apache.org >> >> >> 
>>--------------------------------------------------------------------- >> 
>>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org >> For 
>>additional commands, e-mail: struts-user-help@jakarta.apache.org > > > 
>>--------------------------------------------------------------------- > 
>>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org > For 
>>additional commands, e-mail: struts-user-help@jakarta.apache.org > 
>>--------------------------------------------------------------------- To 
>>unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org For 
>>additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>



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


Re: accessing an image outside my webapp

Posted by Mark Lowe <ma...@talk21.com>.
??
I'm not sure what you mean, you don't forward with this action just 
return null. You can pass what you need as parameters, I just gave you 
an example with the perhaps naive expectation that you might work the 
rest out.


On 15 Jan 2004, at 16:42, Alain Van Vyve wrote:

> that assumes you are not working with jsp anymore for that page ...
> I cannot do that because my page contains a lot of other things ...
>
> Do you think it is possible to integrate that code in my jsp page ?
>
>
> At 15:59 15/01/2004 +0000, you wrote:
>
> Have an action that write the image to the response
>
>
> response.setContentType("image/jpeg");
> response.setHeader("Cache-Control", "no-cache");
>
> OutputStream ou = response.getOutputStream();
>
> String imageStr = "/path to image";
> java.net.URI imgUri = new java.net.URI(imageStr);
> File imageFile = new File(imgUri);
> RandomAccessFile raf = new RandomAccessFile( imageFile, "r" );
> FileInputStream imageFileStream = new FileInputStream(imageFile);
> byte[] image = new byte[(int) imageFile.length()];
>
> while ( (raf.read( image )) > 0 ){
>                 ou.write( image );
> }
>
> ou.flush();
> ou.close();
> return null;
>
> //map the action
>
> <action path="/image" type="com.sparrow.struts.ImageAction" />
>
>
> //
>
> call the action
>
> On 15 Jan 2004, at 15:45, Alain Van Vyve wrote: > I think It is an 
> intersting debate about relative versus absolute > addressing ... > 
> but I'm not relatively but absolutely lost ... > Here is my jsp source 
> ... > What do I have to change ? > > Thanks > > 
> ><image.tiff>name="HotelListForm" > property='<%= "hotelList.hotel[" + 
> i + > "].urlPhoto" %>' />' > alt=' name="HotelListForm" > 
> property='<%= "hotelList.hotel[" + i + > "].urlPhoto" %>' />' > 
> border=0 > > > > > > At 15:44 15/01/2004 +0000, you wrote: >> I think 
> robert it right, i've just tested it too. And i don't think >> that 
> anyone is confused between absolute and relative addressing. >> 
> >>http://www.peevish.co.uk/slang/c.htm>> >> see chocolate fireguard >> 
> >> >> >> On 15 Jan 2004, at 15:28, Martin Gainty wrote: >> >>> Robert 
> >>> The client browser is making a request to a webserver using a >>> 
> "relative >>> address" I think it would be best to understand the 
> difference >>> between >>> "relative addressing" and "absolute 
> addressing" >>> I invite you to read 
> >>>http://www.drizzle.com/~slmndr/tutorial/relabs.html>>> -Martin >>> 
> ----- Original Message ----- >>> From: "Robert Nocera" >>> To: 
> "'Struts Users Mailing List'" >>> Sent: Thursday, January 15, 2004 
> 10:25 AM >>> Subject: RE: accessing an image outside my webapp >>> >>> 
> >>>> I don't think Tomcat does, but your local browser will. You are 
> >>>> sending >>>> your browser a link that tells it to load a file on 
> your file >>>> system. It >>>> will work fine if you are only running 
> locally, but it won't work >>>> if you >>> try >>>> to access that 
> link from a browser on another machine unless that >>>> machine >>>> 
> also has the same file locally. >>>> >>>> -Rob >>>> >>>> -----Original 
> Message----- >>>> From: Mark Lowe [mailto:mark.lowe@talk21.com] >>>> 
> Sent: Thursday, January 15, 2004 10:14 AM >>>> To: Struts Users 
> Mailing List >>>> Subject: Re: accessing an image outside my webapp 
> >>>> >>>> by jingo. it only works!! >>>> >>>> just src rather than 
> href >>>> >>>> >>>> >>>> I thought tomcat wouldn't have access to 
> anything outside the >>>> webapp. >>>> >>>> >>>> On 15 Jan 2004, at 
> 15:03, Richard Hightower wrote: >>>> >>>>> seems like an odd 
> request... but here goes... >>>>> >>>>> >>>>> >>>>> html:img supports 
> three attributes for specifyin the location of an >>>>> image >>>>> 
> forward (referes to a global forward), page (relative to the >>>>> 
> current >>>>> web >>>>> context), and href (any valid URL). >>>>> 
> >>>>> Rick Hightower >>>>> Developer >>>>> >>>>> Struts/J2EE training 
> --http://www.arc-mind.com/strutsCourse.htm>>>>> >>>>> Struts/J2EE 
> consulting -- 
> >>>>>http://www.arc-mind.com/consulting.htm#StrutsMentoring>>>>> >>>>> 
> -----Original Message----- >>>>> From: Alain Van Vyve 
> [mailto:Alain.VanVyve@brussels.sema.slb.com] >>>>> Sent: Thursday, 
> January 15, 2004 7:35 AM >>>>> To: struts-user@jakarta.apache.org 
> >>>>> Subject: accessing an image outside my webapp >>>>> >>>>> >>>>> 
> >>>>> I have a JSP where I would like to show an image located outside 
> my >>>>> webapp >>>>> (e.g. in a c:\photo directory) ... >>>>> >>>>> 
> How to do that with the Struts tag ?? >>>>> >>>>> Thanks >>>>> >>>>> 
> Alain >>>>> >>>>> >>>>> 
> ------------------------------------------------------------------- 
> >>>>> -- >>>>> To unsubscribe, e-mail: 
> struts-user-unsubscribe@jakarta.apache.org >>>>> For additional 
> commands, e-mail: >>>>> struts-user-help@jakarta.apache.org >>>>> 
> >>>>> >>>>> 
> ------------------------------------------------------------------- 
> >>>>> -- >>>>> To unsubscribe, e-mail: 
> struts-user-unsubscribe@jakarta.apache.org >>>>> For additional 
> commands, e-mail: >>>>> struts-user-help@jakarta.apache.org >>>> >>>> 
> >>>> 
> -------------------------------------------------------------------- 
> >>>> - >>>> To unsubscribe, e-mail: 
> struts-user-unsubscribe@jakarta.apache.org >>>> For additional 
> commands, e-mail: struts-user-help@jakarta.apache.org >>>> >>>> >>>> 
> -------------------------------------------------------------------- 
> >>>> - >>>> To unsubscribe, e-mail: 
> struts-user-unsubscribe@jakarta.apache.org >>>> For additional 
> commands, e-mail: struts-user-help@jakarta.apache.org >>>> >>> >>> 
> --------------------------------------------------------------------- 
> >>> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org 
> >>> For additional commands, e-mail: 
> struts-user-help@jakarta.apache.org >> >> >> 
> --------------------------------------------------------------------- 
> >> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org 
> >> For additional commands, e-mail: 
> struts-user-help@jakarta.apache.org > > > 
> --------------------------------------------------------------------- 
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org > 
> For additional commands, e-mail: struts-user-help@jakarta.apache.org > 
> --------------------------------------------------------------------- 
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org For 
> additional commands, e-mail: struts-user-help@jakarta.apache.org


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


Re: accessing an image outside my webapp

Posted by Alain Van Vyve <Al...@brussels.sema.slb.com>.
that assumes you are not working with jsp anymore for that page ...
I cannot do that because my page contains a lot of other things ...

Do you think it is possible to integrate that code in my jsp page ?


At 15:59 15/01/2004 +0000, you wrote:
>Have an action that write the image to the response
>
>
>response.setContentType("image/jpeg");
>response.setHeader("Cache-Control", "no-cache");
>
>OutputStream ou = response.getOutputStream();
>
>String imageStr = "/path to image";
>java.net.URI imgUri = new java.net.URI(imageStr);
>File imageFile = new File(imgUri);
>RandomAccessFile raf = new RandomAccessFile( imageFile, "r" );
>FileInputStream imageFileStream = new FileInputStream(imageFile);
>byte[] image = new byte[(int) imageFile.length()];
>
>while ( (raf.read( image )) > 0 ){
>                 ou.write( image );
>}
>
>ou.flush();
>ou.close();
>return null;
>
>//map the action
>
><action path="/image" type="com.sparrow.struts.ImageAction" />
>
>
>//
>
>call the action
>
>On 15 Jan 2004, at 15:45, Alain Van Vyve wrote: > I think It is an 
>intersting debate about relative versus absolute > addressing ... > but 
>I'm not relatively but absolutely lost ... > Here is my jsp source ... > 
>What do I have to change ? > > Thanks > > > 1bfb385.jpg 
>name="HotelListForm" > property='<%= "hotelList.hotel[" + i + > 
>"].urlPhoto" %>' />' > alt=' name="HotelListForm" > property='<%= 
>"hotelList.hotel[" + i + > "].urlPhoto" %>' />' > border=0 > > > > > > At 
>15:44 15/01/2004 +0000, you wrote: >> I think robert it right, i've just 
>tested it too. And i don't think >> that anyone is confused between 
>absolute and relative addressing. >> >> 
>http://www.peevish.co.uk/slang/c.htm >> >> see chocolate 
>fireguard >> >> >> >> On 15 Jan 2004, at 15:28, Martin Gainty 
>wrote: >> >>> Robert >>> The client browser is making a request to a 
>webserver using a >>> "relative >>> address" I think it would be best to 
>understand the difference >>> between >>> "relative addressing" and 
>"absolute addressing" >>> I invite you to read >>> 
>http://www.drizzle.com/~slmndr/tutorial/relabs.html >>> -Martin >>> ----- 
>Original Message ----- >>> From: "Robert Nocera" >>> To: "'Struts Users 
>Mailing List'" >>> Sent: Thursday, January 15, 2004 10:25 AM >>> Subject: 
>RE: accessing an image outside my webapp >>> >>> >>>> I don't think Tomcat 
>does, but your local browser will. You are >>>> sending >>>> your browser 
>a link that tells it to load a file on your file >>>> system. It >>>> will 
>work fine if you are only running locally, but it won't work >>>> if 
>you >>> try >>>> to access that link from a browser on another machine 
>unless that >>>> machine >>>> also has the same file locally. >>>> >>>> 
>-Rob >>>> >>>> -----Original Message----- >>>> From: Mark Lowe 
>[mailto:mark.lowe@talk21.com] >>>> Sent: Thursday, January 15, 2004 10:14 
>AM >>>> To: Struts Users Mailing List >>>> Subject: Re: accessing an image 
>outside my webapp >>>> >>>> by jingo. it only works!! >>>> >>>> just src 
>rather than href >>>> >>>> >>>> >>>> I thought tomcat wouldn't have access 
>to anything outside the >>>> webapp. >>>> >>>> >>>> On 15 Jan 2004, at 
>15:03, Richard Hightower wrote: >>>> >>>>> seems like an odd request... 
>but here goes... >>>>> >>>>> >>>>> >>>>> html:img supports three 
>attributes for specifyin the location of an >>>>> image >>>>> forward 
>(referes to a global forward), page (relative to the >>>>> current >>>>> 
>web >>>>> context), and href (any valid URL). >>>>> >>>>> Rick 
>Hightower >>>>> Developer >>>>> >>>>> Struts/J2EE training -- 
>http://www.arc-mind.com/strutsCourse.htm >>>>> >>>>> Struts/J2EE 
>consulting -- >>>>> 
>http://www.arc-mind.com/consulting.htm#StrutsMentoring >>>>> >>>>> 
>-----Original Message----- >>>>> From: Alain Van Vyve 
>[mailto:Alain.VanVyve@brussels.sema.slb.com] >>>>> Sent: Thursday, January 
>15, 2004 7:35 AM >>>>> To: struts-user@jakarta.apache.org >>>>> Subject: 
>accessing an image outside my webapp >>>>> >>>>> >>>>> >>>>> I have a JSP 
>where I would like to show an image located outside my >>>>> webapp >>>>> 
>(e.g. in a c:\photo directory) ... >>>>> >>>>> How to do that with the 
>Struts tag ?? >>>>> >>>>> Thanks >>>>> >>>>> Alain >>>>> >>>>> >>>>> 
>------------------------------------------------------------------- >>>>> 
>-- >>>>> To unsubscribe, e-mail: 
>struts-user-unsubscribe@jakarta.apache.org >>>>> For additional commands, 
>e-mail: >>>>> struts-user-help@jakarta.apache.org >>>>> >>>>> >>>>> 
>------------------------------------------------------------------- >>>>> 
>-- >>>>> To unsubscribe, e-mail: 
>struts-user-unsubscribe@jakarta.apache.org >>>>> For additional commands, 
>e-mail: >>>>> struts-user-help@jakarta.apache.org >>>> >>>> >>>> 
>-------------------------------------------------------------------- >>>> 
>- >>>> To unsubscribe, e-mail: 
>struts-user-unsubscribe@jakarta.apache.org >>>> For additional commands, 
>e-mail: struts-user-help@jakarta.apache.org >>>> >>>> >>>> 
>-------------------------------------------------------------------- >>>> 
>- >>>> To unsubscribe, e-mail: 
>struts-user-unsubscribe@jakarta.apache.org >>>> For additional commands, 
>e-mail: struts-user-help@jakarta.apache.org >>>> >>> >>> 
>--------------------------------------------------------------------- >>> 
>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org >>> For 
>additional commands, e-mail: struts-user-help@jakarta.apache.org >> >> >> 
>--------------------------------------------------------------------- >> 
>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org >> For 
>additional commands, e-mail: struts-user-help@jakarta.apache.org > > > 
>--------------------------------------------------------------------- > To 
>unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org > For 
>additional commands, e-mail: struts-user-help@jakarta.apache.org > 
>--------------------------------------------------------------------- To 
>unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org For 
>additional commands, e-mail: struts-user-help@jakarta.apache.org

Re: accessing an image outside my webapp

Posted by Michael McGrady <mi...@michaelmcgrady.com>.
The issue, again, is not about absolute versus relative addressing.  The 
issue is whether you are giving the server the information it needs to 
return the resource.  That can be accomplished in innumerable ways.

At 07:45 AM 1/15/2004, Alain Van Vyve wrote:
>I think It is an intersting debate about relative versus absolute 
>addressing ...
>but I'm not relatively but absolutely lost ...
>Here is my jsp source ...
>What do I have to change ?
>
>Thanks
>
>               <td>
>                 <img src='<bean:write
>                         name="HotelListForm"
>                         property='<%= "hotelList.hotel[" + i + 
> "].urlPhoto" %>' />'
>                         alt='<bean:write
>                         name="HotelListForm"
>                         property='<%= "hotelList.hotel[" + i + 
> "].urlPhoto" %>' />'
>                         border=0 >
>               </td>
>
>
>
>At 15:44 15/01/2004 +0000, you wrote:
>>I think robert it right, i've just tested it too. And i don't think that 
>>anyone is confused between absolute and relative addressing.
>>
>>http://www.peevish.co.uk/slang/c.htm
>>
>>see chocolate fireguard
>>
>>
>>
>>On 15 Jan 2004, at 15:28, Martin Gainty wrote:
>>
>>>Robert
>>>The client browser is making a request to a webserver using a "relative
>>>address" I think it would be best to understand the difference between
>>>"relative addressing" and "absolute addressing"
>>>I invite you to read
>>>http://www.drizzle.com/~slmndr/tutorial/relabs.html
>>>-Martin
>>>----- Original Message -----
>>>From: "Robert Nocera" <rn...@neosllc.com>
>>>To: "'Struts Users Mailing List'" <st...@jakarta.apache.org>
>>>Sent: Thursday, January 15, 2004 10:25 AM
>>>Subject: RE: accessing an image outside my webapp
>>>
>>>
>>>>I don't think Tomcat does, but your local browser will.  You are sending
>>>>your browser a link that tells it to load a file on your file system.  It
>>>>will work fine if you are only running locally, but it won't work if you
>>>try
>>>>to access that link from a browser on another machine unless that machine
>>>>also has the same file locally.
>>>>
>>>>-Rob
>>>>
>>>>-----Original Message-----
>>>>From: Mark Lowe [mailto:mark.lowe@talk21.com]
>>>>Sent: Thursday, January 15, 2004 10:14 AM
>>>>To: Struts Users Mailing List
>>>>Subject: Re: accessing an image outside my webapp
>>>>
>>>>by jingo. it only works!!
>>>>
>>>>just src rather than href
>>>>
>>>><html:img src="file:///test.jpg" />
>>>>
>>>>I thought tomcat wouldn't have access to anything outside the webapp.
>>>>
>>>>
>>>>On 15 Jan 2004, at 15:03, Richard Hightower wrote:
>>>>
>>>>>seems like an odd request... but here goes...
>>>>>
>>>>><html:img href="file://c:/photo directory/foo.gif"/>
>>>>>
>>>>>html:img supports three attributes for specifyin the location of an
>>>>>image
>>>>>forward (referes to a global forward), page (relative to the current
>>>>>web
>>>>>context), and href (any valid URL).
>>>>>
>>>>>Rick Hightower
>>>>>Developer
>>>>>
>>>>>Struts/J2EE training -- http://www.arc-mind.com/strutsCourse.htm
>>>>>
>>>>>Struts/J2EE consulting --
>>>>>http://www.arc-mind.com/consulting.htm#StrutsMentoring
>>>>>
>>>>>-----Original Message-----
>>>>>From: Alain Van Vyve [mailto:Alain.VanVyve@brussels.sema.slb.com]
>>>>>Sent: Thursday, January 15, 2004 7:35 AM
>>>>>To: struts-user@jakarta.apache.org
>>>>>Subject: accessing an image outside my webapp
>>>>>
>>>>>
>>>>>
>>>>>I have a JSP where I would like to show an image located outside my
>>>>>webapp
>>>>>(e.g. in a c:\photo directory)  ...
>>>>>
>>>>>How to do that with the <html:img> Struts tag ??
>>>>>
>>>>>Thanks
>>>>>
>>>>>Alain
>>>>>
>>>>>
>>>>>---------------------------------------------------------------------
>>>>>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>>>>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>>>>
>>>>>
>>>>>---------------------------------------------------------------------
>>>>>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>>>>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>>>
>>>>
>>>>---------------------------------------------------------------------
>>>>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>>>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>>>
>>>>
>>>>---------------------------------------------------------------------
>>>>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>>>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>



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


Re: accessing an image outside my webapp

Posted by Mark Lowe <ma...@talk21.com>.
Have an action that write the image to the response


response.setContentType("image/jpeg");
response.setHeader("Cache-Control", "no-cache");

OutputStream ou = response.getOutputStream();

String imageStr = "/path to image";
java.net.URI imgUri = new java.net.URI(imageStr);
File imageFile = new File(imgUri);
RandomAccessFile raf = new RandomAccessFile( imageFile, "r" );
FileInputStream imageFileStream = new FileInputStream(imageFile);
byte[] image = new byte[(int) imageFile.length()];

while ( (raf.read( image )) > 0 ){
		ou.write( image );
}

ou.flush();
ou.close();
return null;

//map the action

<action path="/image" type="com.sparrow.struts.ImageAction" />


//

call the action

<html:img page="/image.do" />



On 15 Jan 2004, at 15:45, Alain Van Vyve wrote:

> I think It is an intersting debate about relative versus absolute  
> addressing ...
> but I'm not relatively but absolutely lost ...
> Here is my jsp source ...
> What do I have to change ?
>
> Thanks
>
>               <td>
>                 <img src='<bean:write
>                         name="HotelListForm"
>                         property='<%= "hotelList.hotel[" + i +  
> "].urlPhoto" %>' />'
>                         alt='<bean:write
>                         name="HotelListForm"
>                         property='<%= "hotelList.hotel[" + i +  
> "].urlPhoto" %>' />'
>                         border=0 >
>               </td>
>
>
>
> At 15:44 15/01/2004 +0000, you wrote:
>> I think robert it right, i've just tested it too. And i don't think  
>> that anyone is confused between absolute and relative addressing.
>>
>> http://www.peevish.co.uk/slang/c.htm
>>
>> see chocolate fireguard
>>
>>
>>
>> On 15 Jan 2004, at 15:28, Martin Gainty wrote:
>>
>>> Robert
>>> The client browser is making a request to a webserver using a  
>>> "relative
>>> address" I think it would be best to understand the difference  
>>> between
>>> "relative addressing" and "absolute addressing"
>>> I invite you to read
>>> http://www.drizzle.com/~slmndr/tutorial/relabs.html
>>> -Martin
>>> ----- Original Message -----
>>> From: "Robert Nocera" <rn...@neosllc.com>
>>> To: "'Struts Users Mailing List'" <st...@jakarta.apache.org>
>>> Sent: Thursday, January 15, 2004 10:25 AM
>>> Subject: RE: accessing an image outside my webapp
>>>
>>>
>>>> I don't think Tomcat does, but your local browser will.  You are  
>>>> sending
>>>> your browser a link that tells it to load a file on your file  
>>>> system.  It
>>>> will work fine if you are only running locally, but it won't work  
>>>> if you
>>> try
>>>> to access that link from a browser on another machine unless that  
>>>> machine
>>>> also has the same file locally.
>>>>
>>>> -Rob
>>>>
>>>> -----Original Message-----
>>>> From: Mark Lowe [mailto:mark.lowe@talk21.com]
>>>> Sent: Thursday, January 15, 2004 10:14 AM
>>>> To: Struts Users Mailing List
>>>> Subject: Re: accessing an image outside my webapp
>>>>
>>>> by jingo. it only works!!
>>>>
>>>> just src rather than href
>>>>
>>>> <html:img src="file:///test.jpg" />
>>>>
>>>> I thought tomcat wouldn't have access to anything outside the  
>>>> webapp.
>>>>
>>>>
>>>> On 15 Jan 2004, at 15:03, Richard Hightower wrote:
>>>>
>>>>> seems like an odd request... but here goes...
>>>>>
>>>>> <html:img href="file://c:/photo directory/foo.gif"/>
>>>>>
>>>>> html:img supports three attributes for specifyin the location of an
>>>>> image
>>>>> forward (referes to a global forward), page (relative to the  
>>>>> current
>>>>> web
>>>>> context), and href (any valid URL).
>>>>>
>>>>> Rick Hightower
>>>>> Developer
>>>>>
>>>>> Struts/J2EE training -- http://www.arc-mind.com/strutsCourse.htm
>>>>>
>>>>> Struts/J2EE consulting --
>>>>> http://www.arc-mind.com/consulting.htm#StrutsMentoring
>>>>>
>>>>> -----Original Message-----
>>>>> From: Alain Van Vyve [mailto:Alain.VanVyve@brussels.sema.slb.com]
>>>>> Sent: Thursday, January 15, 2004 7:35 AM
>>>>> To: struts-user@jakarta.apache.org
>>>>> Subject: accessing an image outside my webapp
>>>>>
>>>>>
>>>>>
>>>>> I have a JSP where I would like to show an image located outside my
>>>>> webapp
>>>>> (e.g. in a c:\photo directory)  ...
>>>>>
>>>>> How to do that with the <html:img> Struts tag ??
>>>>>
>>>>> Thanks
>>>>>
>>>>> Alain
>>>>>
>>>>>
>>>>> ------------------------------------------------------------------- 
>>>>> --
>>>>> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>>>> For additional commands, e-mail:  
>>>>> struts-user-help@jakarta.apache.org
>>>>>
>>>>>
>>>>> ------------------------------------------------------------------- 
>>>>> --
>>>>> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>>>> For additional commands, e-mail:  
>>>>> struts-user-help@jakarta.apache.org
>>>>
>>>>
>>>> -------------------------------------------------------------------- 
>>>> -
>>>> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>>> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>>>
>>>>
>>>> -------------------------------------------------------------------- 
>>>> -
>>>> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>>> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>


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


Re: accessing an image outside my webapp

Posted by Alain Van Vyve <Al...@brussels.sema.slb.com>.
I think It is an intersting debate about relative versus absolute 
addressing ...
but I'm not relatively but absolutely lost ...
Here is my jsp source ...
What do I have to change ?

Thanks

               <td>
                 <img src='<bean:write
                         name="HotelListForm"
                         property='<%= "hotelList.hotel[" + i + 
"].urlPhoto" %>' />'
                         alt='<bean:write
                         name="HotelListForm"
                         property='<%= "hotelList.hotel[" + i + 
"].urlPhoto" %>' />'
                         border=0 >
               </td>



At 15:44 15/01/2004 +0000, you wrote:
>I think robert it right, i've just tested it too. And i don't think that 
>anyone is confused between absolute and relative addressing.
>
>http://www.peevish.co.uk/slang/c.htm
>
>see chocolate fireguard
>
>
>
>On 15 Jan 2004, at 15:28, Martin Gainty wrote:
>
>>Robert
>>The client browser is making a request to a webserver using a "relative
>>address" I think it would be best to understand the difference between
>>"relative addressing" and "absolute addressing"
>>I invite you to read
>>http://www.drizzle.com/~slmndr/tutorial/relabs.html
>>-Martin
>>----- Original Message -----
>>From: "Robert Nocera" <rn...@neosllc.com>
>>To: "'Struts Users Mailing List'" <st...@jakarta.apache.org>
>>Sent: Thursday, January 15, 2004 10:25 AM
>>Subject: RE: accessing an image outside my webapp
>>
>>
>>>I don't think Tomcat does, but your local browser will.  You are sending
>>>your browser a link that tells it to load a file on your file system.  It
>>>will work fine if you are only running locally, but it won't work if you
>>try
>>>to access that link from a browser on another machine unless that machine
>>>also has the same file locally.
>>>
>>>-Rob
>>>
>>>-----Original Message-----
>>>From: Mark Lowe [mailto:mark.lowe@talk21.com]
>>>Sent: Thursday, January 15, 2004 10:14 AM
>>>To: Struts Users Mailing List
>>>Subject: Re: accessing an image outside my webapp
>>>
>>>by jingo. it only works!!
>>>
>>>just src rather than href
>>>
>>><html:img src="file:///test.jpg" />
>>>
>>>I thought tomcat wouldn't have access to anything outside the webapp.
>>>
>>>
>>>On 15 Jan 2004, at 15:03, Richard Hightower wrote:
>>>
>>>>seems like an odd request... but here goes...
>>>>
>>>><html:img href="file://c:/photo directory/foo.gif"/>
>>>>
>>>>html:img supports three attributes for specifyin the location of an
>>>>image
>>>>forward (referes to a global forward), page (relative to the current
>>>>web
>>>>context), and href (any valid URL).
>>>>
>>>>Rick Hightower
>>>>Developer
>>>>
>>>>Struts/J2EE training -- http://www.arc-mind.com/strutsCourse.htm
>>>>
>>>>Struts/J2EE consulting --
>>>>http://www.arc-mind.com/consulting.htm#StrutsMentoring
>>>>
>>>>-----Original Message-----
>>>>From: Alain Van Vyve [mailto:Alain.VanVyve@brussels.sema.slb.com]
>>>>Sent: Thursday, January 15, 2004 7:35 AM
>>>>To: struts-user@jakarta.apache.org
>>>>Subject: accessing an image outside my webapp
>>>>
>>>>
>>>>
>>>>I have a JSP where I would like to show an image located outside my
>>>>webapp
>>>>(e.g. in a c:\photo directory)  ...
>>>>
>>>>How to do that with the <html:img> Struts tag ??
>>>>
>>>>Thanks
>>>>
>>>>Alain
>>>>
>>>>
>>>>---------------------------------------------------------------------
>>>>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>>>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>>>
>>>>
>>>>---------------------------------------------------------------------
>>>>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>>>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: struts-user-help@jakarta.apache.org


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


Re: accessing an image outside my webapp

Posted by Mark Lowe <ma...@talk21.com>.
I think robert it right, i've just tested it too. And i don't think 
that anyone is confused between absolute and relative addressing.

http://www.peevish.co.uk/slang/c.htm

see chocolate fireguard



On 15 Jan 2004, at 15:28, Martin Gainty wrote:

> Robert
> The client browser is making a request to a webserver using a "relative
> address" I think it would be best to understand the difference between
> "relative addressing" and "absolute addressing"
> I invite you to read
> http://www.drizzle.com/~slmndr/tutorial/relabs.html
> -Martin
> ----- Original Message -----
> From: "Robert Nocera" <rn...@neosllc.com>
> To: "'Struts Users Mailing List'" <st...@jakarta.apache.org>
> Sent: Thursday, January 15, 2004 10:25 AM
> Subject: RE: accessing an image outside my webapp
>
>
>> I don't think Tomcat does, but your local browser will.  You are 
>> sending
>> your browser a link that tells it to load a file on your file system. 
>>  It
>> will work fine if you are only running locally, but it won't work if 
>> you
> try
>> to access that link from a browser on another machine unless that 
>> machine
>> also has the same file locally.
>>
>> -Rob
>>
>> -----Original Message-----
>> From: Mark Lowe [mailto:mark.lowe@talk21.com]
>> Sent: Thursday, January 15, 2004 10:14 AM
>> To: Struts Users Mailing List
>> Subject: Re: accessing an image outside my webapp
>>
>> by jingo. it only works!!
>>
>> just src rather than href
>>
>> <html:img src="file:///test.jpg" />
>>
>> I thought tomcat wouldn't have access to anything outside the webapp.
>>
>>
>> On 15 Jan 2004, at 15:03, Richard Hightower wrote:
>>
>>> seems like an odd request... but here goes...
>>>
>>> <html:img href="file://c:/photo directory/foo.gif"/>
>>>
>>> html:img supports three attributes for specifyin the location of an
>>> image
>>> forward (referes to a global forward), page (relative to the current
>>> web
>>> context), and href (any valid URL).
>>>
>>> Rick Hightower
>>> Developer
>>>
>>> Struts/J2EE training -- http://www.arc-mind.com/strutsCourse.htm
>>>
>>> Struts/J2EE consulting --
>>> http://www.arc-mind.com/consulting.htm#StrutsMentoring
>>>
>>> -----Original Message-----
>>> From: Alain Van Vyve [mailto:Alain.VanVyve@brussels.sema.slb.com]
>>> Sent: Thursday, January 15, 2004 7:35 AM
>>> To: struts-user@jakarta.apache.org
>>> Subject: accessing an image outside my webapp
>>>
>>>
>>>
>>> I have a JSP where I would like to show an image located outside my
>>> webapp
>>> (e.g. in a c:\photo directory)  ...
>>>
>>> How to do that with the <html:img> Struts tag ??
>>>
>>> Thanks
>>>
>>> Alain
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>


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


RE: accessing an image outside my webapp

Posted by Michael McGrady <mi...@michaelmcgrady.com>.
The truth is that "relative" and "absolute" are not that helpful.  The 
thing to understand is that there are protocols or ways of telling the 
computer what to do.  http://www.amazon.com/CHUCKLES.do?forty=twenty 
involves lots of protocols, for example. What they are depends upon the 
setup on the server.

At 07:41 AM 1/15/2004, you wrote:
>Actually Martin, if the link is " file:///test.jpg", as in the message, it
>isn't a relative request.  If it was just "/test.jpg" it would be relative
>to the context of the web-app, but it's not.
>
>-Rob
>
>
>-----Original Message-----
>From: Martin Gainty [mailto:mgainty@hotmail.com]
>Sent: Thursday, January 15, 2004 10:29 AM
>To: Struts Users Mailing List; rnocera@neosllc.com
>Subject: Re: accessing an image outside my webapp
>
>Robert
>The client browser is making a request to a webserver using a "relative
>address" I think it would be best to understand the difference between
>"relative addressing" and "absolute addressing"
>I invite you to read
>http://www.drizzle.com/~slmndr/tutorial/relabs.html
>-Martin
>----- Original Message -----
>From: "Robert Nocera" <rn...@neosllc.com>
>To: "'Struts Users Mailing List'" <st...@jakarta.apache.org>
>Sent: Thursday, January 15, 2004 10:25 AM
>Subject: RE: accessing an image outside my webapp
>
>
> > I don't think Tomcat does, but your local browser will.  You are sending
> > your browser a link that tells it to load a file on your file system.  It
> > will work fine if you are only running locally, but it won't work if you
>try
> > to access that link from a browser on another machine unless that machine
> > also has the same file locally.
> >
> > -Rob
> >
> > -----Original Message-----
> > From: Mark Lowe [mailto:mark.lowe@talk21.com]
> > Sent: Thursday, January 15, 2004 10:14 AM
> > To: Struts Users Mailing List
> > Subject: Re: accessing an image outside my webapp
> >
> > by jingo. it only works!!
> >
> > just src rather than href
> >
> > <html:img src="file:///test.jpg" />
> >
> > I thought tomcat wouldn't have access to anything outside the webapp.
> >
> >
> > On 15 Jan 2004, at 15:03, Richard Hightower wrote:
> >
> > > seems like an odd request... but here goes...
> > >
> > > <html:img href="file://c:/photo directory/foo.gif"/>
> > >
> > > html:img supports three attributes for specifyin the location of an
> > > image
> > > forward (referes to a global forward), page (relative to the current
> > > web
> > > context), and href (any valid URL).
> > >
> > > Rick Hightower
> > > Developer
> > >
> > > Struts/J2EE training -- http://www.arc-mind.com/strutsCourse.htm
> > >
> > > Struts/J2EE consulting --
> > > http://www.arc-mind.com/consulting.htm#StrutsMentoring
> > >
> > > -----Original Message-----
> > > From: Alain Van Vyve [mailto:Alain.VanVyve@brussels.sema.slb.com]
> > > Sent: Thursday, January 15, 2004 7:35 AM
> > > To: struts-user@jakarta.apache.org
> > > Subject: accessing an image outside my webapp
> > >
> > >
> > >
> > > I have a JSP where I would like to show an image located outside my
> > > webapp
> > > (e.g. in a c:\photo directory)  ...
> > >
> > > How to do that with the <html:img> Struts tag ??
> > >
> > > Thanks
> > >
> > > Alain
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
> >
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: struts-user-help@jakarta.apache.org



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


RE: accessing an image outside my webapp

Posted by Robert Nocera <rn...@neosllc.com>.
Actually Martin, if the link is " file:///test.jpg", as in the message, it
isn't a relative request.  If it was just "/test.jpg" it would be relative
to the context of the web-app, but it's not.

-Rob


-----Original Message-----
From: Martin Gainty [mailto:mgainty@hotmail.com] 
Sent: Thursday, January 15, 2004 10:29 AM
To: Struts Users Mailing List; rnocera@neosllc.com
Subject: Re: accessing an image outside my webapp

Robert
The client browser is making a request to a webserver using a "relative
address" I think it would be best to understand the difference between
"relative addressing" and "absolute addressing"
I invite you to read
http://www.drizzle.com/~slmndr/tutorial/relabs.html
-Martin
----- Original Message -----
From: "Robert Nocera" <rn...@neosllc.com>
To: "'Struts Users Mailing List'" <st...@jakarta.apache.org>
Sent: Thursday, January 15, 2004 10:25 AM
Subject: RE: accessing an image outside my webapp


> I don't think Tomcat does, but your local browser will.  You are sending
> your browser a link that tells it to load a file on your file system.  It
> will work fine if you are only running locally, but it won't work if you
try
> to access that link from a browser on another machine unless that machine
> also has the same file locally.
>
> -Rob
>
> -----Original Message-----
> From: Mark Lowe [mailto:mark.lowe@talk21.com]
> Sent: Thursday, January 15, 2004 10:14 AM
> To: Struts Users Mailing List
> Subject: Re: accessing an image outside my webapp
>
> by jingo. it only works!!
>
> just src rather than href
>
> <html:img src="file:///test.jpg" />
>
> I thought tomcat wouldn't have access to anything outside the webapp.
>
>
> On 15 Jan 2004, at 15:03, Richard Hightower wrote:
>
> > seems like an odd request... but here goes...
> >
> > <html:img href="file://c:/photo directory/foo.gif"/>
> >
> > html:img supports three attributes for specifyin the location of an
> > image
> > forward (referes to a global forward), page (relative to the current
> > web
> > context), and href (any valid URL).
> >
> > Rick Hightower
> > Developer
> >
> > Struts/J2EE training -- http://www.arc-mind.com/strutsCourse.htm
> >
> > Struts/J2EE consulting --
> > http://www.arc-mind.com/consulting.htm#StrutsMentoring
> >
> > -----Original Message-----
> > From: Alain Van Vyve [mailto:Alain.VanVyve@brussels.sema.slb.com]
> > Sent: Thursday, January 15, 2004 7:35 AM
> > To: struts-user@jakarta.apache.org
> > Subject: accessing an image outside my webapp
> >
> >
> >
> > I have a JSP where I would like to show an image located outside my
> > webapp
> > (e.g. in a c:\photo directory)  ...
> >
> > How to do that with the <html:img> Struts tag ??
> >
> > Thanks
> >
> > Alain
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>

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


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


Re: accessing an image outside my webapp

Posted by Martin Gainty <mg...@hotmail.com>.
Robert
The client browser is making a request to a webserver using a "relative
address" I think it would be best to understand the difference between
"relative addressing" and "absolute addressing"
I invite you to read
http://www.drizzle.com/~slmndr/tutorial/relabs.html
-Martin
----- Original Message -----
From: "Robert Nocera" <rn...@neosllc.com>
To: "'Struts Users Mailing List'" <st...@jakarta.apache.org>
Sent: Thursday, January 15, 2004 10:25 AM
Subject: RE: accessing an image outside my webapp


> I don't think Tomcat does, but your local browser will.  You are sending
> your browser a link that tells it to load a file on your file system.  It
> will work fine if you are only running locally, but it won't work if you
try
> to access that link from a browser on another machine unless that machine
> also has the same file locally.
>
> -Rob
>
> -----Original Message-----
> From: Mark Lowe [mailto:mark.lowe@talk21.com]
> Sent: Thursday, January 15, 2004 10:14 AM
> To: Struts Users Mailing List
> Subject: Re: accessing an image outside my webapp
>
> by jingo. it only works!!
>
> just src rather than href
>
> <html:img src="file:///test.jpg" />
>
> I thought tomcat wouldn't have access to anything outside the webapp.
>
>
> On 15 Jan 2004, at 15:03, Richard Hightower wrote:
>
> > seems like an odd request... but here goes...
> >
> > <html:img href="file://c:/photo directory/foo.gif"/>
> >
> > html:img supports three attributes for specifyin the location of an
> > image
> > forward (referes to a global forward), page (relative to the current
> > web
> > context), and href (any valid URL).
> >
> > Rick Hightower
> > Developer
> >
> > Struts/J2EE training -- http://www.arc-mind.com/strutsCourse.htm
> >
> > Struts/J2EE consulting --
> > http://www.arc-mind.com/consulting.htm#StrutsMentoring
> >
> > -----Original Message-----
> > From: Alain Van Vyve [mailto:Alain.VanVyve@brussels.sema.slb.com]
> > Sent: Thursday, January 15, 2004 7:35 AM
> > To: struts-user@jakarta.apache.org
> > Subject: accessing an image outside my webapp
> >
> >
> >
> > I have a JSP where I would like to show an image located outside my
> > webapp
> > (e.g. in a c:\photo directory)  ...
> >
> > How to do that with the <html:img> Struts tag ??
> >
> > Thanks
> >
> > Alain
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>

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


Re: accessing an image outside my webapp

Posted by Michael McGrady <mi...@michaelmcgrady.com>.
The Facade is just a pattern.  A simple use of it in this case.  If you 
want the code, request it at michael@michaelmcgrady.com.

At 09:07 AM 1/15/2004, you wrote:
>I kind of thought the example i gave did that, although i did just have
>dummy text for the path to image. Passing a few parameters or setting
>the directory name in a properties file not a huge leap to make (at
>least i thought not).
>
>Any links explaining all this facade business?
>
>On 15 Jan 2004, at 17:02, Michael McGrady wrote:
>
>>This is not quite right.  The only thing you have to do is to give the
>>server whatever it needs to retrieve the data.  This can be a relative
>>or absolute url or a protocol you develop on your own.  The idea is
>>that you have to tell the server what to do.  That will depend on your
>>set up.  My site uses src='RESOURCE.MICHAELMcGRADY?file_type=[some
>>mime or defined type, e.g. gif, jpeg, css]&file_name=[name of the
>>file, not fully qualified]' to return resources, including Flash in
>>the <object> tag.
>>
>>The general solution is to create or obey some protocol which tells
>>the server to return the appropriate output stream to the response
>>object.  My basic class, without the utility/helper classes is:
>>
>>public final class ActionResource
>>     extends Action {
>>   public ActionForward execute(ActionMapping mapping,
>>                                ActionForm form,
>>                                HttpServletRequest request,
>>                                HttpServletResponse response)
>>       throws IOException,
>>              ServletException {
>>     new Facade().handle(request, response);
>>     return null;
>>   }
>>}
>>
>>The Facade class is as follows:
>>public class Facade
>>     implements FacadeIF {
>>   public Facade() {
>>     super();
>>   }
>>   public void handle(HttpServletRequest request,
>>                      HttpServletResponse response) {
>>     new WriteResponse().write(new InitResponse().init(request,
>>response), response);
>>     return;
>>   }
>>}
>>The key is that you use the response object to get the output stream
>>and return a null after writing the object in the response.  This is
>>set up on my system so that the GUI people just have to indicate the
>>type and the name of their resource.  They need know nothing else and
>>all the "crap" about how to locate and to return images, which is
>>always arising, is completely avoided.  Cool, eh?
>>
>>
>>At 07:34 AM 1/15/2004, you wrote:
>>>that makes a bit more sense now, so my original suggestion wasn't
>>>just the crack talking then :)
>>>
>>>On 15 Jan 2004, at 15:25, Robert Nocera wrote:
>>>
>>>>I don't think Tomcat does, but your local browser will.  You are
>>>>sending
>>>>your browser a link that tells it to load a file on your file system.
>>>>It
>>>>will work fine if you are only running locally, but it won't work if
>>>>you try
>>>>to access that link from a browser on another machine unless that
>>>>machine
>>>>also has the same file locally.
>>>>
>>>>-Rob
>>>>
>>>>-----Original Message-----
>>>>From: Mark Lowe [mailto:mark.lowe@talk21.com]
>>>>Sent: Thursday, January 15, 2004 10:14 AM
>>>>To: Struts Users Mailing List
>>>>Subject: Re: accessing an image outside my webapp
>>>>
>>>>by jingo. it only works!!
>>>>
>>>>just src rather than href
>>>>
>>>><html:img src="file:///test.jpg" />
>>>>
>>>>I thought tomcat wouldn't have access to anything outside the webapp.
>>>>
>>>>
>>>>On 15 Jan 2004, at 15:03, Richard Hightower wrote:
>>>>
>>>>>seems like an odd request... but here goes...
>>>>>
>>>>><html:img href="file://c:/photo directory/foo.gif"/>
>>>>>
>>>>>html:img supports three attributes for specifyin the location of an
>>>>>image
>>>>>forward (referes to a global forward), page (relative to the current
>>>>>web
>>>>>context), and href (any valid URL).
>>>>>
>>>>>Rick Hightower
>>>>>Developer
>>>>>
>>>>>Struts/J2EE training -- http://www.arc-mind.com/strutsCourse.htm
>>>>>
>>>>>Struts/J2EE consulting --
>>>>>http://www.arc-mind.com/consulting.htm#StrutsMentoring
>>>>>
>>>>>-----Original Message-----
>>>>>From: Alain Van Vyve [mailto:Alain.VanVyve@brussels.sema.slb.com]
>>>>>Sent: Thursday, January 15, 2004 7:35 AM
>>>>>To: struts-user@jakarta.apache.org
>>>>>Subject: accessing an image outside my webapp
>>>>>
>>>>>
>>>>>
>>>>>I have a JSP where I would like to show an image located outside my
>>>>>webapp
>>>>>(e.g. in a c:\photo directory)  ...
>>>>>
>>>>>How to do that with the <html:img> Struts tag ??
>>>>>
>>>>>Thanks
>>>>>
>>>>>Alain
>>>>>
>>>>>
>>>>>-------------------------------------------------------------------- -
>>>>>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>>>>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>>>>
>>>>>
>>>>>-------------------------------------------------------------------- -
>>>>>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>>>>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>>>
>>>>
>>>>---------------------------------------------------------------------
>>>>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>>>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>>>
>>>>
>>>>---------------------------------------------------------------------
>>>>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>>>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>



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


Re: accessing an image outside my webapp

Posted by Mark Lowe <ma...@talk21.com>.
I kind of thought the example i gave did that, although i did just have  
dummy text for the path to image. Passing a few parameters or setting  
the directory name in a properties file not a huge leap to make (at  
least i thought not).

Any links explaining all this facade business?

On 15 Jan 2004, at 17:02, Michael McGrady wrote:

> This is not quite right.  The only thing you have to do is to give the  
> server whatever it needs to retrieve the data.  This can be a relative  
> or absolute url or a protocol you develop on your own.  The idea is  
> that you have to tell the server what to do.  That will depend on your  
> set up.  My site uses src='RESOURCE.MICHAELMcGRADY?file_type=[some  
> mime or defined type, e.g. gif, jpeg, css]&file_name=[name of the  
> file, not fully qualified]' to return resources, including Flash in  
> the <object> tag.
>
> The general solution is to create or obey some protocol which tells  
> the server to return the appropriate output stream to the response  
> object.  My basic class, without the utility/helper classes is:
>
> public final class ActionResource
>     extends Action {
>   public ActionForward execute(ActionMapping mapping,
>                                ActionForm form,
>                                HttpServletRequest request,
>                                HttpServletResponse response)
>       throws IOException,
>              ServletException {
>     new Facade().handle(request, response);
>     return null;
>   }
> }
>
> The Facade class is as follows:
> public class Facade
>     implements FacadeIF {
>   public Facade() {
>     super();
>   }
>   public void handle(HttpServletRequest request,
>                      HttpServletResponse response) {
>     new WriteResponse().write(new InitResponse().init(request,  
> response), response);
>     return;
>   }
> }
> The key is that you use the response object to get the output stream  
> and return a null after writing the object in the response.  This is  
> set up on my system so that the GUI people just have to indicate the  
> type and the name of their resource.  They need know nothing else and  
> all the "crap" about how to locate and to return images, which is  
> always arising, is completely avoided.  Cool, eh?
>
>
> At 07:34 AM 1/15/2004, you wrote:
>> that makes a bit more sense now, so my original suggestion wasn't  
>> just the crack talking then :)
>>
>> On 15 Jan 2004, at 15:25, Robert Nocera wrote:
>>
>>> I don't think Tomcat does, but your local browser will.  You are  
>>> sending
>>> your browser a link that tells it to load a file on your file system.
>>> It
>>> will work fine if you are only running locally, but it won't work if  
>>> you try
>>> to access that link from a browser on another machine unless that  
>>> machine
>>> also has the same file locally.
>>>
>>> -Rob
>>>
>>> -----Original Message-----
>>> From: Mark Lowe [mailto:mark.lowe@talk21.com]
>>> Sent: Thursday, January 15, 2004 10:14 AM
>>> To: Struts Users Mailing List
>>> Subject: Re: accessing an image outside my webapp
>>>
>>> by jingo. it only works!!
>>>
>>> just src rather than href
>>>
>>> <html:img src="file:///test.jpg" />
>>>
>>> I thought tomcat wouldn't have access to anything outside the webapp.
>>>
>>>
>>> On 15 Jan 2004, at 15:03, Richard Hightower wrote:
>>>
>>>> seems like an odd request... but here goes...
>>>>
>>>> <html:img href="file://c:/photo directory/foo.gif"/>
>>>>
>>>> html:img supports three attributes for specifyin the location of an
>>>> image
>>>> forward (referes to a global forward), page (relative to the current
>>>> web
>>>> context), and href (any valid URL).
>>>>
>>>> Rick Hightower
>>>> Developer
>>>>
>>>> Struts/J2EE training -- http://www.arc-mind.com/strutsCourse.htm
>>>>
>>>> Struts/J2EE consulting --
>>>> http://www.arc-mind.com/consulting.htm#StrutsMentoring
>>>>
>>>> -----Original Message-----
>>>> From: Alain Van Vyve [mailto:Alain.VanVyve@brussels.sema.slb.com]
>>>> Sent: Thursday, January 15, 2004 7:35 AM
>>>> To: struts-user@jakarta.apache.org
>>>> Subject: accessing an image outside my webapp
>>>>
>>>>
>>>>
>>>> I have a JSP where I would like to show an image located outside my
>>>> webapp
>>>> (e.g. in a c:\photo directory)  ...
>>>>
>>>> How to do that with the <html:img> Struts tag ??
>>>>
>>>> Thanks
>>>>
>>>> Alain
>>>>
>>>>
>>>> -------------------------------------------------------------------- 
>>>> -
>>>> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>>> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>>>
>>>>
>>>> -------------------------------------------------------------------- 
>>>> -
>>>> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>>> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>
>>


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


Re: accessing an image outside my webapp

Posted by Michael McGrady <mi...@michaelmcgrady.com>.
This is not quite right.  The only thing you have to do is to give the 
server whatever it needs to retrieve the data.  This can be a relative or 
absolute url or a protocol you develop on your own.  The idea is that you 
have to tell the server what to do.  That will depend on your set up.  My 
site uses src='RESOURCE.MICHAELMcGRADY?file_type=[some mime or defined 
type, e.g. gif, jpeg, css]&file_name=[name of the file, not fully 
qualified]' to return resources, including Flash in the <object> tag.

The general solution is to create or obey some protocol which tells the 
server to return the appropriate output stream to the response object.  My 
basic class, without the utility/helper classes is:

public final class ActionResource
     extends Action {
   public ActionForward execute(ActionMapping mapping,
                                ActionForm form,
                                HttpServletRequest request,
                                HttpServletResponse response)
       throws IOException,
              ServletException {
     new Facade().handle(request, response);
     return null;
   }
}

The Facade class is as follows:
public class Facade
     implements FacadeIF {
   public Facade() {
     super();
   }
   public void handle(HttpServletRequest request,
                      HttpServletResponse response) {
     new WriteResponse().write(new InitResponse().init(request, response), 
response);
     return;
   }
}
The key is that you use the response object to get the output stream and 
return a null after writing the object in the response.  This is set up on 
my system so that the GUI people just have to indicate the type and the 
name of their resource.  They need know nothing else and all the "crap" 
about how to locate and to return images, which is always arising, is 
completely avoided.  Cool, eh?


At 07:34 AM 1/15/2004, you wrote:
>that makes a bit more sense now, so my original suggestion wasn't just the 
>crack talking then :)
>
>On 15 Jan 2004, at 15:25, Robert Nocera wrote:
>
>>I don't think Tomcat does, but your local browser will.  You are sending
>>your browser a link that tells it to load a file on your file system.
>>It
>>will work fine if you are only running locally, but it won't work if you try
>>to access that link from a browser on another machine unless that machine
>>also has the same file locally.
>>
>>-Rob
>>
>>-----Original Message-----
>>From: Mark Lowe [mailto:mark.lowe@talk21.com]
>>Sent: Thursday, January 15, 2004 10:14 AM
>>To: Struts Users Mailing List
>>Subject: Re: accessing an image outside my webapp
>>
>>by jingo. it only works!!
>>
>>just src rather than href
>>
>><html:img src="file:///test.jpg" />
>>
>>I thought tomcat wouldn't have access to anything outside the webapp.
>>
>>
>>On 15 Jan 2004, at 15:03, Richard Hightower wrote:
>>
>>>seems like an odd request... but here goes...
>>>
>>><html:img href="file://c:/photo directory/foo.gif"/>
>>>
>>>html:img supports three attributes for specifyin the location of an
>>>image
>>>forward (referes to a global forward), page (relative to the current
>>>web
>>>context), and href (any valid URL).
>>>
>>>Rick Hightower
>>>Developer
>>>
>>>Struts/J2EE training -- http://www.arc-mind.com/strutsCourse.htm
>>>
>>>Struts/J2EE consulting --
>>>http://www.arc-mind.com/consulting.htm#StrutsMentoring
>>>
>>>-----Original Message-----
>>>From: Alain Van Vyve [mailto:Alain.VanVyve@brussels.sema.slb.com]
>>>Sent: Thursday, January 15, 2004 7:35 AM
>>>To: struts-user@jakarta.apache.org
>>>Subject: accessing an image outside my webapp
>>>
>>>
>>>
>>>I have a JSP where I would like to show an image located outside my
>>>webapp
>>>(e.g. in a c:\photo directory)  ...
>>>
>>>How to do that with the <html:img> Struts tag ??
>>>
>>>Thanks
>>>
>>>Alain
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>

Re: accessing an image outside my webapp

Posted by Mark Lowe <ma...@talk21.com>.
that makes a bit more sense now, so my original suggestion wasn't just 
the crack talking then :)

On 15 Jan 2004, at 15:25, Robert Nocera wrote:

> I don't think Tomcat does, but your local browser will.  You are 
> sending
> your browser a link that tells it to load a file on your file system.  
> It
> will work fine if you are only running locally, but it won't work if 
> you try
> to access that link from a browser on another machine unless that 
> machine
> also has the same file locally.
>
> -Rob
>
> -----Original Message-----
> From: Mark Lowe [mailto:mark.lowe@talk21.com]
> Sent: Thursday, January 15, 2004 10:14 AM
> To: Struts Users Mailing List
> Subject: Re: accessing an image outside my webapp
>
> by jingo. it only works!!
>
> just src rather than href
>
> <html:img src="file:///test.jpg" />
>
> I thought tomcat wouldn't have access to anything outside the webapp.
>
>
> On 15 Jan 2004, at 15:03, Richard Hightower wrote:
>
>> seems like an odd request... but here goes...
>>
>> <html:img href="file://c:/photo directory/foo.gif"/>
>>
>> html:img supports three attributes for specifyin the location of an
>> image
>> forward (referes to a global forward), page (relative to the current
>> web
>> context), and href (any valid URL).
>>
>> Rick Hightower
>> Developer
>>
>> Struts/J2EE training -- http://www.arc-mind.com/strutsCourse.htm
>>
>> Struts/J2EE consulting --
>> http://www.arc-mind.com/consulting.htm#StrutsMentoring
>>
>> -----Original Message-----
>> From: Alain Van Vyve [mailto:Alain.VanVyve@brussels.sema.slb.com]
>> Sent: Thursday, January 15, 2004 7:35 AM
>> To: struts-user@jakarta.apache.org
>> Subject: accessing an image outside my webapp
>>
>>
>>
>> I have a JSP where I would like to show an image located outside my
>> webapp
>> (e.g. in a c:\photo directory)  ...
>>
>> How to do that with the <html:img> Struts tag ??
>>
>> Thanks
>>
>> Alain
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>


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


RE: accessing an image outside my webapp

Posted by Robert Nocera <rn...@neosllc.com>.
I don't think Tomcat does, but your local browser will.  You are sending
your browser a link that tells it to load a file on your file system.  It
will work fine if you are only running locally, but it won't work if you try
to access that link from a browser on another machine unless that machine
also has the same file locally.

-Rob

-----Original Message-----
From: Mark Lowe [mailto:mark.lowe@talk21.com] 
Sent: Thursday, January 15, 2004 10:14 AM
To: Struts Users Mailing List
Subject: Re: accessing an image outside my webapp

by jingo. it only works!!

just src rather than href

<html:img src="file:///test.jpg" />

I thought tomcat wouldn't have access to anything outside the webapp.


On 15 Jan 2004, at 15:03, Richard Hightower wrote:

> seems like an odd request... but here goes...
>
> <html:img href="file://c:/photo directory/foo.gif"/>
>
> html:img supports three attributes for specifyin the location of an 
> image
> forward (referes to a global forward), page (relative to the current 
> web
> context), and href (any valid URL).
>
> Rick Hightower
> Developer
>
> Struts/J2EE training -- http://www.arc-mind.com/strutsCourse.htm
>
> Struts/J2EE consulting --
> http://www.arc-mind.com/consulting.htm#StrutsMentoring
>
> -----Original Message-----
> From: Alain Van Vyve [mailto:Alain.VanVyve@brussels.sema.slb.com]
> Sent: Thursday, January 15, 2004 7:35 AM
> To: struts-user@jakarta.apache.org
> Subject: accessing an image outside my webapp
>
>
>
> I have a JSP where I would like to show an image located outside my 
> webapp
> (e.g. in a c:\photo directory)  ...
>
> How to do that with the <html:img> Struts tag ??
>
> Thanks
>
> Alain
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>


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


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


Re: accessing an image outside my webapp

Posted by Mark Lowe <ma...@talk21.com>.
by jingo. it only works!!

just src rather than href

<html:img src="file:///test.jpg" />

I thought tomcat wouldn't have access to anything outside the webapp.


On 15 Jan 2004, at 15:03, Richard Hightower wrote:

> seems like an odd request... but here goes...
>
> <html:img href="file://c:/photo directory/foo.gif"/>
>
> html:img supports three attributes for specifyin the location of an 
> image
> forward (referes to a global forward), page (relative to the current 
> web
> context), and href (any valid URL).
>
> Rick Hightower
> Developer
>
> Struts/J2EE training -- http://www.arc-mind.com/strutsCourse.htm
>
> Struts/J2EE consulting --
> http://www.arc-mind.com/consulting.htm#StrutsMentoring
>
> -----Original Message-----
> From: Alain Van Vyve [mailto:Alain.VanVyve@brussels.sema.slb.com]
> Sent: Thursday, January 15, 2004 7:35 AM
> To: struts-user@jakarta.apache.org
> Subject: accessing an image outside my webapp
>
>
>
> I have a JSP where I would like to show an image located outside my 
> webapp
> (e.g. in a c:\photo directory)  ...
>
> How to do that with the <html:img> Struts tag ??
>
> Thanks
>
> Alain
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>


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


RE: accessing an image outside my webapp

Posted by Richard Hightower <rh...@arc-mind.com>.
seems like an odd request... but here goes...

<html:img href="file://c:/photo directory/foo.gif"/>

html:img supports three attributes for specifyin the location of an image
forward (referes to a global forward), page (relative to the current web
context), and href (any valid URL).

Rick Hightower
Developer

Struts/J2EE training -- http://www.arc-mind.com/strutsCourse.htm

Struts/J2EE consulting --
http://www.arc-mind.com/consulting.htm#StrutsMentoring

-----Original Message-----
From: Alain Van Vyve [mailto:Alain.VanVyve@brussels.sema.slb.com]
Sent: Thursday, January 15, 2004 7:35 AM
To: struts-user@jakarta.apache.org
Subject: accessing an image outside my webapp



I have a JSP where I would like to show an image located outside my webapp
(e.g. in a c:\photo directory)  ...

How to do that with the <html:img> Struts tag ??

Thanks

Alain


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


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