Given that in my daily work routine I browse several huge documentation libraries, I have two problems:
So I decided to write a mod_ziplook equivalent as a Java servlet, using the excellent TrueZIP library: returning an HTML page to a browser is extremely simple, for example http://localhost/docs/jdk-142-docs.zip/jdk-142-docs/api/java/lang/String.html resolves to this handleFile() method where all the "real" work is done by the catTo() call:
- sometimes I do not have any network access and thus I cannot access anything online, thus no documentation [sic...]
- if I store everything locally, it takes up way too much space (JDKs, ATG, Oracle, etc.)
So I decided to write a mod_ziplook equivalent as a Java servlet, using the excellent TrueZIP library: returning an HTML page to a browser is extremely simple, for example http://localhost/docs/jdk-142-docs.zip/jdk-142-docs/api/java/lang/String.html resolves to this handleFile() method where all the "real" work is done by the catTo() call:
private void handleFile (de.schlichtherle.io.File pFileEntry,
HttpServletRequest pReq,
HttpServletResponse pRes) throws IOException {
// get the content type of the file to be transmitted
String mimeType = getServletContext().getMimeType(pFileEntry.getName());
// get the size of the uncompressed data
long fileSize = pFileEntry.length();
// write the response headers
pRes.setContentType(mimeType);
pRes.setContentLength((int)fileSize);
// write the response data
pFileEntry.catTo(pRes.getOutputStream());
}
Download the result and deploy the dist/zipdocs.war archive to your favorite container. I'm currently using the Sun Java System Web Server and it works just dandy :-).