oreilly.comSafari Books Online.Conferences.

Apache FAQ
Linux FAQ

Log in to particpate

   Apache FAQ > E. Configuration Questions
Question:  Why do my Java app[let]s give me plain text when I request an URL from an Apache server?

As of version 1.2, Apache is an HTTP/1.1 (HyperText Transfer Protocol version 1.1) server. This fact is reflected in the protocol version that's included in the response headers sent to a client when processing a request. Unfortunately, low-level Web access classes included in the Java Development Kit (JDK) version 1.0.2 expect to see the version string "HTTP/1.0" and do not correctly interpret the "HTTP/1.1" value Apache is sending (this part of the response is a declaration of what the server can do rather than a declaration of the dialect of the response). The result is that the JDK methods do not correctly parse the headers, and include them with the document content by mistake.

This is definitely a bug in the JDK 1.0.2 foundation classes from Sun, and it has been fixed in version 1.1. However, the classes in question are part of the virtual machine environment, which means they're part of the Web browser (if Java-enabled) or the Java environment on the client system - so even if you develop your classes with a recent JDK, the eventual users might encounter the problem. The classes involved are replaceable by vendors implementing the Java virtual machine environment, and so even those that are based upon the 1.0.2 version may not have this problem.

In the meantime, a workaround is to tell Apache to "fake" an HTTP/1.0 response to requests that come from the JDK methods; this can be done by including a line such as the following in your server configuration files:

BrowserMatch Java1.0 force-response-1.0
BrowserMatch JDK/1.0 force-response-1.0

More information about this issue can be found in the Java and HTTP/1.1 page at the Apache web site.

This FAQ is from Apache Server Frequently Asked Questions

Sponsored by: