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

JarURLConnection does not return the right content type (getContentType())

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Closed
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 1.2.1
    • Fix Version/s: 1.2.2
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      1.2.2
    • CPU:
      x86
    • OS:
      windows_95
    • Verification:
      Not verified

      Description



      Name: dbT83986 Date: 04/29/99


      getContentType() of JarURLConnection (the one under sun.net.*) isn't returning a valid content type for .java files; shouldn't getContentType() recognize .java source files?

      The following

      import java.security.*;
      import java.io.*;
      import java.net.*;

      class test {
      public test() {}
      public static void main(String args[]) {
      try {
      URL u = new URL("jar:file:/c://temp//test.jar!/test.java");
      JarURLConnection uc = (JarURLConnection)u.openConnection();
      //System.out.println(uc.getInputStream());
      System.out.println(uc.getContentType());
      } catch (Exception e) {
      System.out.println("error here");
      e.printStackTrace();
      }
      }
      }
      returns null. In fact it returns null as long as that URL does not refer to a JarFile (JarEntry is null).
      In the case where it is refering to a JarFile, it returns "x-java/jar"
      Since the generic getContent() uses getContentType() to find the right content handler, this leads to another problem:
      If getContent() is called in the test case above, it will raise an UnknownServiceException saying no content-type. I
      suspect it is due to the null returned by getContentType()
      (Review ID: 57640)
      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              michaelm Michael McMahon
              Reporter:
              dblairsunw Dave Blair (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: