Re: file path

2003-03-19 Thread Dan Allen
> There is absolutely no guarantee that webapp resources even *have* a "file
> path" at all -- it's perfectly legal for the container to run your
> application directly from a WAR file (Tomcat has an option for that), or
> dump your static resources into a database, or anywhere else it wants.
> 
> To read a resource file like this, use the following:
> 
>   InputStream is =
> getServletContext().getResourceAsStream("/file.dat");
Yep, was actually cruising the sourcecode and just got this a few
minutes ago.  The servlet context has all the nice methods for file
access ;)

> where the path you pass starts with a slash, and is relative to the
> context root.  This is how Struts reads your struts-config.xml file, by
> the way, using a typical path like "/WEB-INF/struts-config.xml".
> 
> As a side note, placing your data file directly in the context root
> directory like this makes it possible for clients to access the file
> directly.  If you don't want this (in other words, if the file is only for
> internal use by your app), you can put it in /WEB-INF instead.
Naturally. I was actually writing a custom taglib to check for the
existence of an asset (graphic file, which is a headshot of a
member) and to use it as a logic:present like tag.  I am actually
going to start a new thread with the sourcecode for that.

Dan

-- 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
Daniel Allen, <[EMAIL PROTECTED]>
http://www.mojavelinux.com/
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
There is no such thing as a casual knowledge of xslt, either 
you know everything about it or you are sitting in the creek.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: file path

2003-03-19 Thread Craig R. McClanahan


On Wed, 19 Mar 2003, Dan Allen wrote:

> Date: Wed, 19 Mar 2003 13:19:49 -0600
> From: Dan Allen <[EMAIL PROTECTED]>
> Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>
> To: Struts-User List <[EMAIL PROTECTED]>
> Subject: Re: file path
>
>
> Dan Allen ([EMAIL PROTECTED]) wrote:
>
> > Assuming I am storing a public file in my web directory who's real
> > path is
> >
> > /var/tomcat/webapps/program/file.dat
> >
> > How would I reference that file in my Action class in order to read
> > in the data?  My concern of course is how to get the path info
> > preceding my application, namely /var/tomcat/webapps/program/
> >
> > Thanks!
> >
> > Dan
>
> So even the struts-upload example doesn't get into this, because it
> allows you to type in a filename but it treats it as a full unix
> path, not a relative path.  How can my struts application work with
> files inside the current application.  Surely there must be a way to
> deal with real file paths of these files.

There is absolutely no guarantee that webapp resources even *have* a "file
path" at all -- it's perfectly legal for the container to run your
application directly from a WAR file (Tomcat has an option for that), or
dump your static resources into a database, or anywhere else it wants.

To read a resource file like this, use the following:

  InputStream is =
getServletContext().getResourceAsStream("/file.dat");

where the path you pass starts with a slash, and is relative to the
context root.  This is how Struts reads your struts-config.xml file, by
the way, using a typical path like "/WEB-INF/struts-config.xml".

As a side note, placing your data file directly in the context root
directory like this makes it possible for clients to access the file
directly.  If you don't want this (in other words, if the file is only for
internal use by your app), you can put it in /WEB-INF instead.

>
> Dan

Craig

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: file path

2003-03-19 Thread Dan Allen
perhaps org.apache.commons.resources.file.web.WebappFileResources?

Dan

-- 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
Daniel Allen, <[EMAIL PROTECTED]>
http://www.mojavelinux.com/
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
"When you're raised by the Jesuits, you become either obedient 
or impertinent" 
 -- Jack McCoy, "Law and Order"
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: file path

2003-03-19 Thread Dan Allen

Dan Allen ([EMAIL PROTECTED]) wrote:

> Assuming I am storing a public file in my web directory who's real
> path is
> 
> /var/tomcat/webapps/program/file.dat
> 
> How would I reference that file in my Action class in order to read
> in the data?  My concern of course is how to get the path info
> preceding my application, namely /var/tomcat/webapps/program/ 
> 
> Thanks!
> 
> Dan

So even the struts-upload example doesn't get into this, because it
allows you to type in a filename but it treats it as a full unix
path, not a relative path.  How can my struts application work with
files inside the current application.  Surely there must be a way to
deal with real file paths of these files.

Dan

-- 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
Daniel Allen, <[EMAIL PROTECTED]>
http://www.mojavelinux.com/
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
Since no one can ever know for certain whether or not his own 
view of creation is the correct one, it is impossible for him 
to know if someone else's is the wrong one.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: File path from

2002-11-14 Thread Huynh Ngoc Huy
  Yes, I have
  Thanks,
  Huy

--- Dan Tran <[EMAIL PROTECTED]> wrote:
> Huy, have you seen the struts-upload example? it is
> in the struts 1.1
> distribution
> -D
> - Original Message -
> From: "Huynh Ngoc Huy" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Thursday, November 14, 2002 6:23 PM
> Subject: File path from 
> 
> 
> >   Dear group,
> >   How can we get the file path from  ?
> >   Thanks,
> >   Huy
> >
> >
> > __
> > Do you Yahoo!?
> > Yahoo! Web Hosting - Let the expert host your site
> > http://webhosting.yahoo.com
> >
> > --
> > To unsubscribe, e-mail:
> 
> > For additional commands, e-mail:
> 
> >
> 
> --
> To unsubscribe, e-mail:  
> 
> For additional commands, e-mail:
> 
> 


__
Do you Yahoo!?
Yahoo! Web Hosting - Let the expert host your site
http://webhosting.yahoo.com

--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re: File path from

2002-11-14 Thread Dan Tran
Huy, have you seen the struts-upload example? it is in the struts 1.1
distribution
-D
- Original Message -
From: "Huynh Ngoc Huy" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, November 14, 2002 6:23 PM
Subject: File path from 


>   Dear group,
>   How can we get the file path from  ?
>   Thanks,
>   Huy
>
>
> __
> Do you Yahoo!?
> Yahoo! Web Hosting - Let the expert host your site
> http://webhosting.yahoo.com
>
> --
> To unsubscribe, e-mail:

> For additional commands, e-mail:

>

--
To unsubscribe, e-mail:   
For additional commands, e-mail: