Ubuntu's tomcat5.5 package installs quite easily, and sets up a server at port 8180. I still have to figure out how to nicely integrate it with the Apache server on port 80, though. Suggestions much appreciated.
From then on, one can add new JSP pages by creating a 'webapp' in /usr/share/tomcat5.5-webapps. The basic structure looks like:
mb-examples.xmlJust copying the large CDK jar (the one with all the third party libraries) into WEB-INF/lib/ did not work for me, but unjaring it into WEB-INF/classes/ seem to work fine.
Then, you can just add Java code using the CDK library for what ever you like. The following (simple) example JSP page, takes one parameter, a molecular formula. This could be the input given in a FORM, but the below page does not deal with that situation yet:
<%@ page import="java.util.*,org.openscience.cdk.*,org.openscience.cdk.tools.*" %>Now, a lot of improvement can be achieved. For example, the <head> stuff can be split out in a header.include. And, after proper integration with the Apache server, rewrites could be used to create a REST service. But, the above is just to give you an idea.
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
String mf = request.getParameter( "mf" );
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="E.L. Willighagen">
<td><%= mf %></td>
MFAnalyser analyser = new MFAnalyser(mf, new Molecule());
double accurateMass = Math.round(analyser.getMass()*10000.0)/10000.0;
<td>Mono-isotopic Accurate Mass:</td>
<td><%= accurateMass %></td>
In case you wonder, this work is related to the opensource MetWare database software development our group is involved in.