if (!uri.endsWith("jar")) {
in = getResourceAsStream(uri);
if (in == null)
throw new JasperException(Constants.getString("jsp.error.tld_not_found",
new Object[] {TLD}));
// Now parse the tld.
parseTLD(in);
}
// FIXME Take this stuff out when taglib changes are thoroughly tested.
// 2000.11.15 commented out the 'copy to work dir' section,
// which I believe is what this FIXME comment referred to. (pierred)
if (uri.endsWith("jar")) {
if (!isRelativeURI(uri)) {
url = new URL(uri);
in = url.openStream();
} else {
relativeURL = true;
in = getResourceAsStream(uri);
}
zin = new ZipInputStream(in);
this.jarEntries = new Hashtable();
this.ctxt = ctxt;
/* NOT COMPILED
// First copy this file into our work directory!
{
File jspFile = new File(ctxt.getJspFile());
String parent = jspFile.getParent();
String jarFileName = ctxt.getOutputDir();
if (parent != null) {
jarFileName = jarFileName + File.separatorChar +
parent;
}
File jspDir = new File(jarFileName);
jspDir.mkdirs();
if (relativeURL)
jarFileName = jarFileName+File.separatorChar+new File(uri).getName();
else
jarFileName = jarFileName+File.separatorChar+
new File(url.getFile()).getName();
Constants.message("jsp.message.copyinguri",
new Object[] { uri, jarFileName },
Logger.DEBUG);
if (relativeURL)
copy(getResourceAsStream(uri),
jarFileName);
else
copy(url.openStream(), jarFileName);
ctxt.addJar(jarFileName);
}
*/ // END NOT COMPILED
boolean tldFound = false;
ZipEntry entry;
while ((entry = zin.getNextEntry()) != null) {
if (entry.getName().equals(TLD)) {
/*******
* This hack is necessary because XML reads until the end
* of an inputstream -- does not use available()
* -- and closes the inputstream when it can't
* read no more.
*/
// BEGIN HACK
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int b;
while (zin.available() != 0) {
b = zin.read();
if (b == -1)
break;
baos.write(b);
}
baos.close();
ByteArrayInputStream bais
= new ByteArrayInputStream(baos.toByteArray());
// END HACK
tldFound = true;
parseTLD(bais);
} else {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int b;
while (zin.available() != 0) {
b = zin.read();
if (b == -1)
break;
baos.write(b);
}
baos.close();
jarEntries.put(entry.getName(), baos.toByteArray());
}
zin.closeEntry();
}
if (!tldFound)
throw new JasperException(Constants.getString("jsp.error.tld_not_found",
new Object[] {
TLD
}
));
} // Take this out (END of if(endsWith("jar")))