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

R

RonS

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
 
W

Wendy Smoak

RonS said:
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.
 
R

RonS

Wendy said:
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.
 
W

Wendy Smoak

RonS said:
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?
 
R

RonS

Wendy said:
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.
 
R

RonS

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top