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

Discussion in 'Java' started by RonS, Apr 13, 2005.

  1. RonS

    RonS Guest

    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
    RonS, Apr 13, 2005
    #1
    1. Advertising

  2. RonS

    Wendy Smoak Guest

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

    "RonS" <> 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
    Wendy Smoak, Apr 13, 2005
    #2
    1. Advertising

  3. RonS

    RonS Guest

    Re: Finding the absolute path to the root (or other known workingdirectory) of a 'standard' J2EE web server.

    Wendy Smoak wrote:

    > "RonS" <> 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.
    RonS, Apr 13, 2005
    #3
  4. RonS

    Wendy Smoak Guest

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

    "RonS" <> 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
    Wendy Smoak, Apr 13, 2005
    #4
  5. RonS

    RonS Guest

    Re: Finding the absolute path to the root (or other known workingdirectory) of a 'standard' J2EE web server.

    Wendy Smoak wrote:
    > "RonS" <> 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.
    RonS, Apr 14, 2005
    #5
  6. RonS

    RonS Guest

    Re: Finding the absolute path to the root (or other known workingdirectory) of a 'standard' J2EE web server.

    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" <> 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?
    >
    RonS, Apr 16, 2005
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Oliver
    Replies:
    4
    Views:
    7,162
    Jeffrey Palermo [MCP]
    Dec 5, 2004
  2. Paul
    Replies:
    5
    Views:
    191
    Kyle Peterson
    Mar 20, 2006
  3. James Byrne
    Replies:
    3
    Views:
    555
    James Byrne
    Sep 14, 2010
  4. Bob Walton
    Replies:
    9
    Views:
    185
    David K. Wall
    Sep 26, 2003
  5. Roy Smith
    Replies:
    1
    Views:
    320
    Gelonida N
    Jun 19, 2012
Loading...

Share This Page