Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Finding the absolute path to the root (or other known working directory)of a 'standard' J2EE web server.

Reply
Thread Tools

Finding the absolute path to the root (or other known working directory)of a 'standard' J2EE web server.

 
 
RonS
Guest
Posts: n/a
 
      04-12-2005
I'm working with JBoss on two different servers with two different versions
and two different host systems. I'm storing some data which I want to access
from multiple apps in a directory for which I'm able to compute the address.
This all works fine, but I'm wondering what happens if I move to another
'brand' of server.

Is there a configuration directory which is guaranteed to exist on all J2EE
compliant servers for which I can compute the absolute address from within my
applications?

Thanks - Ron
 
Reply With Quote
 
 
 
 
Wendy Smoak
Guest
Posts: n/a
 
      04-13-2005
"RonS" <(E-Mail Removed)> wrote:
> I'm working with JBoss on two different servers with two different

versions
> and two different host systems. I'm storing some data which I want to

access
> from multiple apps in a directory for which I'm able to compute the

address.
> This all works fine, but I'm wondering what happens if I move to another
> 'brand' of server.
>
> Is there a configuration directory which is guaranteed to exist on all

J2EE
> compliant servers for which I can compute the absolute address from within

my
> applications?


The only thing you're guaranteed by the specification is a place to write
temporary files. If you need to know the exact location of something, there
are some options including a context param in web.xml or a .properties file
that you read in. This also gives the server admin the chance to pick where
they want you writing files, and to make sure that the user the container is
running as actually has permissions to write there.

--
Wendy


 
Reply With Quote
 
 
 
 
RonS
Guest
Posts: n/a
 
      04-13-2005
Wendy Smoak wrote:

> "RonS" <(E-Mail Removed)> wrote:
>
>>I'm working with JBoss on two different servers with two different

>
> versions
>
>>and two different host systems. I'm storing some data which I want to

>
> access
>
>>from multiple apps in a directory for which I'm able to compute the

>
> address.
>
>>This all works fine, but I'm wondering what happens if I move to another
>>'brand' of server.
>>
>>Is there a configuration directory which is guaranteed to exist on all

>
> J2EE
>
>>compliant servers for which I can compute the absolute address from within

>
> my
>
>>applications?

>
>
> The only thing you're guaranteed by the specification is a place to write
> temporary files. If you need to know the exact location of something, there
> are some options including a context param in web.xml or a .properties file
> that you read in. This also gives the server admin the chance to pick where
> they want you writing files, and to make sure that the user the container is
> running as actually has permissions to write there.
>

Wendy
Thanks for your reply (again). I'm using javax.servlet.context.tempdir to
compute the path to the server 'base'. Then putting my file in a known
directory under that. So, I think, if javax.servlet.context.tempdir is
guaranteed to exist in all servers I should be OK.

Thanks - Ron

P.S. Still haven't found my 'double execution' of Actions problem.
 
Reply With Quote
 
Wendy Smoak
Guest
Posts: n/a
 
      04-13-2005
"RonS" <(E-Mail Removed)> wrote

> Thanks for your reply (again). I'm using javax.servlet.context.tempdir to
> compute the path to the server 'base'. Then putting my file in a known
> directory under that. So, I think, if javax.servlet.context.tempdir is
> guaranteed to exist in all servers I should be OK.


What you're doing is not guaranteed to work. The Servlet container is
required to provide a temp directory per webapp. It is NOT required to
place that temp directory anywhere in particular. See SRV.3.7.1 of the
Servlet 2.3 Specification.

What about a distributed environment with multiple instances of the servlet
container? What if the user the container is executing as does not have
write permission to this location you have come up with based on the temp
directory?

--
Wendy


 
Reply With Quote
 
RonS
Guest
Posts: n/a
 
      04-14-2005
Wendy Smoak wrote:
> "RonS" <(E-Mail Removed)> wrote
>
>
>>Thanks for your reply (again). I'm using javax.servlet.context.tempdir to
>>compute the path to the server 'base'. Then putting my file in a known
>>directory under that. So, I think, if javax.servlet.context.tempdir is
>>guaranteed to exist in all servers I should be OK.

>
>
> What you're doing is not guaranteed to work. The Servlet container is
> required to provide a temp directory per webapp. It is NOT required to
> place that temp directory anywhere in particular. See SRV.3.7.1 of the
> Servlet 2.3 Specification.
>
> What about a distributed environment with multiple instances of the servlet
> container? What if the user the container is executing as does not have
> write permission to this location you have come up with based on the temp
> directory?
>


Yes, I can see the problem of temp directory not necessarily being defined as
a subdirectory of the servlet container 'base'. I'll read the spec, but I'm
sure you're correct. However, it seems unlikely that it would be configured
outside the servlet container directory space as this would bring up similar
issues with permissions ... wouldn't it?

The file is read-only to the application so only an admin needs write
permission to configure or change it. I'm not sure of the implications of a
distributed environment with multiple instances ... I guess that would be a
configuration issue to ensure all the file is replicated properly.
 
Reply With Quote
 
RonS
Guest
Posts: n/a
 
      04-16-2005
OK Wendy, you got me ... I see from the spec that the application(s) are
guaranteed nothing about the location of the temp directory.

It would seem the only guaranteed way to do what I want is to make the config
file available from another source ... even if that is another small app on
the same server. Or do you have another suggestion?

Wendy Smoak wrote:
> "RonS" <(E-Mail Removed)> wrote
>
>
>>Thanks for your reply (again). I'm using javax.servlet.context.tempdir to
>>compute the path to the server 'base'. Then putting my file in a known
>>directory under that. So, I think, if javax.servlet.context.tempdir is
>>guaranteed to exist in all servers I should be OK.

>
>
> What you're doing is not guaranteed to work. The Servlet container is
> required to provide a temp directory per webapp. It is NOT required to
> place that temp directory anywhere in particular. See SRV.3.7.1 of the
> Servlet 2.3 Specification.
>
> What about a distributed environment with multiple instances of the servlet
> container? What if the user the container is executing as does not have
> write permission to this location you have come up with based on the temp
> directory?
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Finding absolute path of imported module? Roy Smith Python 1 06-19-2012 09:46 PM
How does one get an absolute absolute file path? James Byrne Ruby 3 09-14-2010 06:02 PM
How to access web.sitemap file from other virtual directories other than the current application root folder? hvajja@gmail.com ASP .Net 0 08-07-2006 08:26 PM
Finding absolute file path on server? Paul ASP General 5 03-20-2006 03:35 AM
absolute path versus relative path in JSP Matt Java 3 07-08-2004 08:31 PM



Advertisments