save structure file

User 217d927b31

15-06-2009 23:30:00

I have the marvinsketch applet embedded in a webpage. I can use the script  "


msketch_param("mol", "../../../mols-2d/caffeine.mol");   "  to load the strucuture from the sever.
Can someone tell me the script to save the struture to the sever, also where I can find
those scripts and their usage format.

Thanks


ChemAxon 7c2d26e5cf

16-06-2009 14:52:13

I recommend to get the molecule in the proper format from the applet and post it to the server where you can save it with some server side code.


You can post molecule by the following way:


Create a form on your web page (where the applet is located) with a button and a hidden field:


<form name="molform" method="post" action="display-result.jsp">
<input type="button" value="Submit molfile"
onClick="getMol('mol')">
<input type="hidden" name="molecule">
</form>
When the button "Submit molfile" is pushed, the molecule is getMol(String) method is invoked that retrieves the molecule from the applet and post it to the given jsp page.

<script language="JavaScript" src="../../../marvin.js"></script><script language="JavaScript">function getMol(format) {
if((document.MSketch != null) {
var s = document.MSketch.getMol(format);
s = unix2local(s); // Convert "\n" to local line separator
document.molform.molecule.value = s;
document.molform.submit();
} else {
alert("Cannot import molecule:\n" +
"no JavaScript to Java communication in your browser.\n");
}
}
msketch_name="MSketch";
msketch_begin("../../..",540,480);
msketch_param("mol","../../../mols-2d/caffeine.mol");
msketch_end();
//--></script>

On server side, you can use various solutions to retrieve and process data. In this example, the form is posted to a JSP page that process it. But it can be any other server side solution depend on your server.