Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4208685

Should URL.getFile() return "index.html" or "/index.html"?

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P3 P3
    • None
    • 1.2.0
    • core-libs
    • sparc
    • solaris_2.5



      Name: mgC56079 Date: 02/04/99


      The URL.getFile() for "http://www.sun.com/index.html" returns "/index.html" in JDK 1.2.

      The spec for java.net.URL says:
       * <blockquote><pre>
       * http://www.ncsa.uiuc.edu/demoweb/url-primer.html
       * </pre></blockquote>
       * <p>
       * In general, a URL can be broken into several parts. The previous
       * example of a URL indicates that the protocol to use is
       * <code>http</code> (HyperText Transport Protocol) and that the
       * information resides on a host machine named
       * <code>www.ncsa.uiuc.edu&lt;/code>. The information on that host
       * machine is named <code>demoweb/url-primer.html</code>. The exact

      This means the file name for the URL should be "demoweb/url-primer.html", not
      "/demoweb/url-primer.html" as getFile() returns.

      The RFC 1738 also says the initial slash is not a part of path name (see item 3.1):

              //<user>:<password>@<host>:<port>/<url-path>

          [skip]
       
          url-path
              The rest of the locator consists of data specific to the
              scheme, and is known as the "url-path". It supplies the
              details of how the specified resource can be accessed. Note
              that the "/" between the host (or port) and the url-path is
              NOT part of the url-path.

      (note the last sentence)

      This might be a compatibility problem. See the message below:

      >
      > To: ###@###.###
      > X-Reflected-By: ###@###.###
      > From: ###@###.### ()
      > Subject: Class library incompatibilities?
      > Date: 3 Feb 1999 16:45:58 GMT
      > NNTP-Posting-Host: asha.eng.sun.com
      > Originator: ag@asha
      >
      >
      > For java.net.URL, how is the getFile() method defined?
      >
      > Given the URL http://www.sun.com/index.html, the method getFile() returns
      >
      > /index.html on Solaris (default Sun class libraries)
      > index.html on Linux (without the initial "slash")
      >
      > Java Class Libraries vol. 1 (Chan, Lee, Kramer) Page 1809 seems to suggest
      > the latter is the correct response.
      >
      > Anyone else seen this? Any suggestions?
      >
      > thanks
      >
      > -amit
      >
      > --
      > Amit Gupta **** Sun Microsystems **** ###@###.###
      >
      >


      ======================================================================

            Unassigned Unassigned
            gorsunw Gor Gor (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: