String fullName = pathInfo; if (pathInfo.startsWith("/")) fullName = pathInfo.substring(1); int idx = fullName.indexOf('/'); jarName = fullName.substring(0, idx); String classPath = fullName.substring(idx + 1); if ((pathInfo.lastIndexOf('.') != -1) && !pathInfo.endsWith(".class")) { JSPhandler.ResourceStream rs = jh.getResourceAsStream(jarName, classPath); if (rs == null) { response.sendError(response.SC_NOT_FOUND); return; } // HTTP cache handling code java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat( "EEE, dd MMM yyyy hh:mm:ss"); sdf.setTimeZone(TimeZone.getTimeZone("GMT")); String strLastModified = sdf.format( new Date(rs.lastModified)); String strETag = "E" + rs.lastModified; String ifNoneMatch = request.getHeader( "If-None-Match"); if (ifNoneMatch != null) { if (ifNoneMatch.equals(strETag)) { response.setDateHeader("Expires", System.currentTimeMillis() + jh.expiration * 1000); response.sendError( response.SC_NOT_MODIFIED); return; } } String ifModified = request.getHeader( "If-Modified-Since"); if (ifModified != null) { if (ifModified.equals(strLastModified)) { response.setDateHeader("Expires", System.currentTimeMillis() + jh.expiration * 1000); response.sendError( response.SC_NOT_MODIFIED); return; } } response.setHeader("Cache-control", "public"); response.setDateHeader("Date", System.currentTimeMillis()); response.setHeader("Last-Modified", strLastModified + " GMT"); response.setHeader("ETag", "E"+rs.lastModified); response.setDateHeader("Expires", System.currentTimeMillis() + jh.expiration * 1000); // end of HTTP cache handling code ServletContext sc = getServletContext(); response.setContentType( sc.getMimeType(classPath)); BufferedInputStream bis = new BufferedInputStream(rs.is); BufferedOutputStream bos = new BufferedOutputStream( response.getOutputStream()); int i; while((i = bis.read()) != -1) bos.write(i); bos.flush(); bis.close(); return; }