interPool = new Stack();
Interpreter interp;
synchronized (servletContext) {
AppContext ctx = (AppContext)servletContext.getAttribute(appCtxAttrName);
if (ctx == null) {
ctx = new AppContext();
servletContext.setAttribute(appCtxAttrName, ctx);
interp = getInterpreter();
// Read the heap file
String realPath = servletContext.getRealPath("/");
String heapFileName = realPath + config.getInitParameter("heap");
System.out.println("loading heap " + heapFileName);
File heapFile = new File(heapFileName);
try {
FileInputStream fis = new FileInputStream(heapFileName);
BufferedInputStream bis
= new BufferedInputStream(fis, (int)heapFile.length());
GZIPInputStream gzis = new GZIPInputStream(bis);
DataInputStream dis
= new DataInputStream(new BufferedInputStream(gzis));
ctx.loadEnv(interp, dis);
} catch (IOException ex) {
System.err.println("Error loading heap:" + ex);
ex.printStackTrace();
throw new ServletException(ex);
}
ctx.setEvaluator("eval");
}
else {
interp = getInterpreter();
}
}