getRealPath()

Discussion in 'Java' started by Manish Hatwalne, Aug 14, 2003.

  1. The documentation of -
    public java.lang.String getRealPath(java.lang.String path)
    of ServletContext says -

    <quote>
    The real path returned will be in a form appropriate to the computer and
    operating system on which the servlet container is running, including the
    proper path separators. This method returns null if the servlet container
    cannot translate the virtual path to a real path for any reason (such as
    when the content is being made available from a .war archive).
    </quote>

    What would be the workaround in this case? I need to deploy my application
    as a war file and I also need to get the real path of a web document.

    I can store the path in the web.xml file, but want to avaoid it as long as
    it is possible. Is there any other way of doing this?

    TIA,
    - Manish
     
    Manish Hatwalne, Aug 14, 2003
    #1
    1. Advertising

  2. Manish Hatwalne

    Chris Smith Guest

    Manish Hatwalne wrote:
    > The documentation of -
    > public java.lang.String getRealPath(java.lang.String path)
    > of ServletContext says -
    >
    > <quote>
    > The real path returned will be in a form appropriate to the computer and
    > operating system on which the servlet container is running, including the
    > proper path separators. This method returns null if the servlet container
    > cannot translate the virtual path to a real path for any reason (such as
    > when the content is being made available from a .war archive).
    > </quote>
    >
    > What would be the workaround in this case? I need to deploy my application
    > as a war file and I also need to get the real path of a web document.


    You seem to have missed something... there's a reason that getRealPath
    returns null in that context: If you deploy your web application as a
    war file, there IS no real path for any of your web app resources,
    because there's no file corresponding to any resource. They are all in
    the war file. You're essentially saying "I need a house with no
    windows, but I also need the ability to open a window."

    So since the question you asked is inherently without meaning, what is
    your real requirement?

    --
    www.designacourse.com
    The Easiest Way to Train Anyone... Anywhere.

    Chris Smith - Lead Software Developer/Technical Trainer
    MindIQ Corporation
     
    Chris Smith, Aug 15, 2003
    #2
    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. Steve Burrus

    getRealPath() Method

    Steve Burrus, Mar 4, 2004, in forum: Java
    Replies:
    0
    Views:
    698
    Steve Burrus
    Mar 4, 2004
  2. Steve Burrus

    Need help w. the getRealPath() Method

    Steve Burrus, Mar 5, 2004, in forum: Java
    Replies:
    0
    Views:
    402
    Steve Burrus
    Mar 5, 2004
  3. Vidya
    Replies:
    0
    Views:
    8,787
    Vidya
    Jun 1, 2005
Loading...

Share This Page