[APACHE DOCUMENTATION]

Java and HTTP/1.1


The Apache Group has received a few reports concerning problems accessing Apache 1.2 sites using Java applications and applets. Investigation revealed a problem in Sun's JDK (Java Development Kit) version 1.0.2.

So, What's The Problem?

The symptom of the problem is this: Java classes involved in accessing Web URLs (such as URLConnection and friends) will return the HTTP headers as well as the document contents. That is, if you use URLConnection to access an URL such as http://localhost/foo.gif and your localhost server responds with HTTP/1.1 headers, your code is going to receive the textual headers before the actual image contents.

What's The Solution?

This problem was identified and corrected by Sun in September of 1996, and the fix is present in the JDK 1.1 and JDK 1.1.1 releases. So any applets or applications that run in either of these post-1.0.2 environments should work correctly.

In addition, the foundation class which contained the problem is one that is labeled as a "manufacturer specific handler", and is typically supplied by the vendor porting the Java virtual machine environment. So there's a good chance that fairly-recent browsers won't have this problem, because the vendors will have provided an implementation class that didn't inherit the problem in the JDK 1.0.2 class library.

Is There a Workaround?

Yes and no:

Yes
If you run an Apache 1.2 server, you can instruct the server to "fake" HTTP/1.0 responses by adding BrowserMatch directives to the configuration files. (See the Apache FAQ for exact details.) By doing this, any client on the net that accesses your server using Java and the JDK 1.0.2 class library will get the response it expects.

No
If you as an user are encountering this problem, there is no real workaround (other than contacting the webmaster of the server(s) involved and bringing it to their attention). Your best action is to upgrade to a "safe" virtual machine such as JDK 1.1.1 or Mozilla 3.01 or later.


Thanks for identifying this problem and its causes, workarounds, and solutions are due to many individuals around the net.