You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by bobd <gr...@yahoo.com> on 2003/03/11 07:52:20 UTC

relative path problem

This is a rather silly problem I have been putting off
and now I really need to fix it...

In my Struts app, bean classes are parsing and writing
XML files on disk.  These files are currently being
pulled in using a full directory path! (i.e.
"/usr/local/...)  Attempts to use relative paths (from
the location of the bean .class file) have not been
successful.  In my view layer, JSPs can use relative
paths just fine.  What's the trick?

thanks,

-bob

__________________________________________________
Do you Yahoo!?
Yahoo! Web Hosting - establish your business online
http://webhosting.yahoo.com

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


Re: relative path problem

Posted by Steve Parker <st...@naweb.com>.
Not sure, but perhaps can you get the relative path by calling 
java.lang.system.getProperty('prop_name')

not sure what the identifier for relative path is though..


On Wed, 12 Mar 2003 10:36:09 -0800 (PST), bobd wrote
> That is my problem...how do you get the relative path
> (in an action class)?  Could you provide or point me
> to some example code?
> 
> OR, even an example of using
> 'ApplicationResources.Properties' to read in a path
> value would satisfy me.
> 
> thanks
> 
> --- Stephen Smithstone <sk...@lchost.co.uk>
> wrote:
> > try using an action that gets the relative path then
> > pass that path to the 
> > bean maybe 
> > 
> > 
> > 
> > On Tuesday 11 March 2003 6:52 am, bobd wrote:
> > > This is a rather silly problem I have been putting
> > off
> > > and now I really need to fix it...
> > >
> > > In my Struts app, bean classes are parsing and
> > writing
> > > XML files on disk.  These files are currently
> > being
> > > pulled in using a full directory path! (i.e.
> > > "/usr/local/...)  Attempts to use relative paths
> > (from
> > > the location of the bean .class file) have not
> > been
> > > successful.  In my view layer, JSPs can use
> > relative
> > > paths just fine.  What's the trick?
> > >
> > > thanks,
> > >
> > > -bob
> > >
> > > __________________________________________________
> > > Do you Yahoo!?
> > > Yahoo! Web Hosting - establish your business
> > online
> > > http://webhosting.yahoo.com
> > >
> > >
> >
> ---------------------------------------------------------------------
> > > 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
> > 
> 
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Web Hosting - establish your business online
> http://webhosting.yahoo.com
> 
> ---------------------------------------------------------------------
> 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: relative path problem

Posted by bobd <gr...@yahoo.com>.
That is my problem...how do you get the relative path
(in an action class)?  Could you provide or point me
to some example code?

OR, even an example of using
'ApplicationResources.Properties' to read in a path
value would satisfy me.

thanks


--- Stephen Smithstone <sk...@lchost.co.uk>
wrote:
> try using an action that gets the relative path then
> pass that path to the 
> bean maybe 
> 
> 
> 
> On Tuesday 11 March 2003 6:52 am, bobd wrote:
> > This is a rather silly problem I have been putting
> off
> > and now I really need to fix it...
> >
> > In my Struts app, bean classes are parsing and
> writing
> > XML files on disk.  These files are currently
> being
> > pulled in using a full directory path! (i.e.
> > "/usr/local/...)  Attempts to use relative paths
> (from
> > the location of the bean .class file) have not
> been
> > successful.  In my view layer, JSPs can use
> relative
> > paths just fine.  What's the trick?
> >
> > thanks,
> >
> > -bob
> >
> > __________________________________________________
> > Do you Yahoo!?
> > Yahoo! Web Hosting - establish your business
> online
> > http://webhosting.yahoo.com
> >
> >
>
---------------------------------------------------------------------
> > 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
> 


__________________________________________________
Do you Yahoo!?
Yahoo! Web Hosting - establish your business online
http://webhosting.yahoo.com

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


Re: relative path problem

Posted by Stephen Smithstone <sk...@lchost.co.uk>.
try using an action that gets the relative path then pass that path to the 
bean maybe 



On Tuesday 11 March 2003 6:52 am, bobd wrote:
> This is a rather silly problem I have been putting off
> and now I really need to fix it...
>
> In my Struts app, bean classes are parsing and writing
> XML files on disk.  These files are currently being
> pulled in using a full directory path! (i.e.
> "/usr/local/...)  Attempts to use relative paths (from
> the location of the bean .class file) have not been
> successful.  In my view layer, JSPs can use relative
> paths just fine.  What's the trick?
>
> thanks,
>
> -bob
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Web Hosting - establish your business online
> http://webhosting.yahoo.com
>
> ---------------------------------------------------------------------
> 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: relative path problem

Posted by Jeff Smith <je...@centralscheduling.net>.
I find that paths can be stated as absolute, from the root of my web-app.

So, for example, my style sheets are linked as:
<link rel="stylesheet" type="text/css"
href="/myappname/styles/default.css"/>

This seems to work, but it introduces a secondary problem. What if I change
the name of my app? I suppose I could always put the app-name as a constant
and reference it that way...

I have seen a couple of examples that use "./styles/default.css" so I am
assuming that works too. But I haven't actually tried changing my references
yet. That would solve my secondary problem as well as your initial one.

Hope that helps,
Jefficus


----- Original Message -----
From: "bobd" <gr...@yahoo.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Monday, March 10, 2003 11:52 PM
Subject: relative path problem


> This is a rather silly problem I have been putting off
> and now I really need to fix it...
>
> In my Struts app, bean classes are parsing and writing
> XML files on disk.  These files are currently being
> pulled in using a full directory path! (i.e.
> "/usr/local/...)  Attempts to use relative paths (from
> the location of the bean .class file) have not been
> successful.  In my view layer, JSPs can use relative
> paths just fine.  What's the trick?
>
> thanks,
>
> -bob
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Web Hosting - establish your business online
> http://webhosting.yahoo.com
>
> ---------------------------------------------------------------------
> 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