public class JSPhandler {
String cachePath;
HashMap classEntries = new HashMap();
Properties remoteLocProp = new Properties();
ServletConfig servletConfig;
JSPhandler(ServletConfig sc,String contextPath){
servletConfig = sc;
cachePath = sc.getInitParameter("cachePath");
if (cachePath == null)
cachePath = "C:/temp";
String remoteLocFile = sc.getInitParameter(
"remoteLocations");
if (remoteLocFile == null)
remoteLocFile = cachePath + contextPath +
".properties";
File f = new File(remoteLocFile);
if ((f != null) && f.exists()) {
try {
remoteLocProp.load(new DataInputStream(
new FileInputStream(f)));
}
catch(Exception e) {}
}
}
final synchronized Servlet get(String pathInfo)
throws ServletException {
String fullName = pathInfo;
if (pathInfo.startsWith("/"))
fullName = pathInfo.substring(1);
int idx = fullName.indexOf('/');
String jarName = fullName.substring(0, idx);
String classPath = fullName.substring(idx + 1);
ClassEntry ce = null;
if (classEntries.containsKey(jarName)) {
ce = (ClassEntry)classEntries.get(jarName);
return ce.get(classPath);
}
ce = new ClassEntry(this, jarName);
classEntries.put(jarName, ce);
return ce.get(classPath);
}
}