User 55ffa2f197
25-07-2013 21:34:17
Hi I am using following simple jsp script to generate mol image from tomcat server. I am sending in valid Mol and format as parameter. However i have noticed that there are imageio files generated when running this webapp, the temp image file got written into CATALINA_TEMPDIR as defined in Tomcat env file. My Tomcat setting is the default setting, i did not do any customization. The temp dir is : /apps/ibmapp/apache-tomcat-7.0.39/temp, the temp file has the name like : imageio7267496980310869538.tmp.
Can you take a look at my script, see if we can figure out where the temp files come from. Once the number of the temp files reach ~3000, Tomcat will hang giving an error of "Too many open files ...." . Though i can delete the temp files while the server is running, but the files, marked as deleted still being considered by Tomcat as open. So once that happens i have to stop and restart the server, this is quite annoying.
Thanks for your help
Dong
Here is the script:
<%@page import="java.io.*,
java.net.URLDecoder,
chemaxon.formats.MolImporter,
chemaxon.struc.Molecule"%>
<%
ServletOutputStream outs = null;
try {
// Retrieving GET/POST parameters
String format = request.getParameter("format");
String molstring = null;
molstring = request.getParameter("mol");
String type = format.indexOf(":") == -1 ? format : format.substring(0, format.indexOf(":"));
response.setContentType("image/" + type);
Molecule mol = null;
mol = MolImporter.importMol(molstring);
byte[] b = mol.toBinFormat(format);
outs = response.getOutputStream();
//out.clear();
//out = pageContext.pushBody();
outs.write(b,0,b.length);
outs.flush();
} catch(Throwable t) {
t.printStackTrace();
} finally {
try{
outs.close();
}catch (Exception inner){
}
}
%>