displaying the molecule structure in JSP

User 08026ff1f0

22-10-2004 17:11:49

Hi ,


I am writing a JSP code to retreive a particular compound from Oracle database and display its structure.I am able to retreive the cd_structure of the compound but i am not able to display it using the applet.Can anyone pls tell me in detail how to display the compound structure using the applet and also how to initialize it.








Bhargav

ChemAxon 43e6884a7a

22-10-2004 19:15:26

Please see the JSP example in the jchem/examples/jsp1_x directory.


File: searchresults.jsp


Try it alive: http://www.jchem.com/examples/jsp1_x/index.jsp


Setup of the example: http://www.jchem.com/examples/jsp1_x/setup.html


Relevant section in the documentation: http://www.jchem.com/doc/guide/search/index.html#sss_retrieve

User 08026ff1f0

22-10-2004 21:40:02

Hi,


I have actually seen the JSP code in the examples . When I am trying to run the JSP file it says java.lang.ClassNotFoundException: JMView..This class is not being loaded...One more thing, in the developers section in www.jchem.com, u have given a code to which performs SQL querying on database and retrieves the structure and then displays it..In that u have used the function DatabaseTools.readLongColumn(rs,2).While compiling there is an error which says that the class DatabaseTools doesnt have this function.


I have checked out the API of this class and it doesnt contain the function readLongColumns...Please help me out..Its sort of urgent.Thanks ..

ChemAxon 9c0afc9aaf

23-10-2004 08:20:12

Quote:
When I am trying to run the JSP file it says java.lang.ClassNotFoundException: JMView..This class is not being loaded...
Where you see this error message. I suppose in the Java console, and not in the output of Tomcat ?


This is an indication, that the Marvin applet cannot be loaded for some reason. Please see the following lines in the JSP example pages:











Code:



<script LANGUAGE="JavaScript1.1" SRC="../../marvin/marvin.js">


    </script>


    <script LANGUAGE="JavaScript1.1">


    <!--


    mview_name="mview";


    mview_begin("../../marvin",


            "<%= cols*cellWidth+cols-1 %>",


            "<%= rows*cellHeight+rows-1 %>");








The Marvin directory should be available in the mentioned location.


This is should be the case in the example that ships with the package (if you set the context in the server as described), but probably your files refer to an inappropriate location, or your server configuration must be revised.





Regarding the problem with DatabaseTools.readLongColumn(), this method has been renamed to readBytes() just before the release:





http://www.jchem.com/doc/api/chemaxon/util/DatabaseTools.html#readBytes(java.sql.ResultSet,%20int)





Obviously we forgot to change the Developer's Guide accordingly.


Thank you for pointing this out, and sorry for the inconvenience.


We will fix the document ASAP.





Szilard

User 08026ff1f0

24-10-2004 19:56:50

Hi ,





Thanks for the reply. Now i am able to display the applet using my JSP page but it is not displaying the structure inside it. I am using jchem 2.2.1 which doesnt have the function 'readBytes' in it. So I am using





String dbMolfile = new String(rs.getBytes("cd_structure"),"ASCII");


%>


mview_param("cell 1",


"|<%= HTMLTools.convertForJavaScript(


dbMolfile) %>");


<%








to convert it into string instead of


String dbMolfile = new String(readBytes(rs,2),"ASCII");


%>


mview_param("cell 1",


"|<%= HTMLTools.convertForJavaScript(


dbMolfile) %>");


<%





will the above thing work..Since my page is displaying the applet clearly and all the functions that we can perform on the applet like animation etc are working..But the structure is not getting displayed inside ..So I think that there is some problem with the above part where we extract the cd_structures column from the database and convert into a string to display in the applet..Please help me out ASAP. Thank u





Bhargav

ChemAxon 9c0afc9aaf

25-10-2004 11:22:06

1. You have an extra space in the parameter name.


You should write "cell1" instead of "cell 1".


Also cells start with "cell0"





http://www.chemaxon.com/marvin/doc/dev/viewman.html#advanced.cell





http://www.chemaxon.com/marvin/doc/dev/example-view2.1.html





2. If you want to display a single molecule, you can also use the "mol" parameter:





http://www.chemaxon.com/marvin/doc/dev/viewman.html#parameters.mol





Please see the Marvin Developers' Guide for further examples and information:








http://www.chemaxon.com/marvin/doc/dev/index.html

User 08026ff1f0

25-10-2004 14:57:42

Hi,





Thank You very much. I got the problem fixed up. I shud have used cell0 instead of cell1. Its working now.





Bhargav

User 08026ff1f0

28-10-2004 17:06:06

hi,





Can you please tell me how to pass the structure that has been drawn in marvin sketch


to another JSP page so that it can be used to perform queries and display the structures (using html forms and not Java Script). Also please tell me how to retrieve the drawn structure in the other JSP page.


Thanks.





Bhargav

ChemAxon 9c0afc9aaf

29-10-2004 07:37:20

Hi,





The source of this example is available in the JChem package:





http://www.jchem.com/examples/jsp1_x/index.jsp





The source is under jchem/examples/jsp1_x/





Retrieving the structure is done in the query.jsp by JavaScript, and posted in a form's hidden input


(JavaScript is a necessary thing here, otherwise the structure cannot be retrieved):





Code:



        form = document.queryForm;


    form.action = "initsearch.jsp" + location.search;


    form.molfile.value = document.[b]msketch.getMol('mrv');[/b]


    if(checkForm())


        form.submit();








The form definition:





Code:



 <form method="post" name="queryForm">


 <input type="hidden" name="molfile">








The posted value is retrieved in initsearch.jsp:


Code:



String molfile = (String)request.getParameter("molfile");


User 08026ff1f0

29-12-2004 20:08:55

Hi,





I am using Jchem 2.2.1. I am writing code in JSP that performs substructure searching . As a result I get all the compound ids whose structures have the drawn structure as a part of them. What should I do if i want to get only compound ids that have molecular wt(or compound id) greater than or less than some number .





Bhargav

ChemAxon 9c0afc9aaf

04-01-2005 13:58:40

Hi,





In JChem 2.2.1 there are two ways to filter the structures:





1. JChemSearch.setStringToAppend:





http://www.jchem.com/doc/api/chemaxon/jchem/db/JChemSearch.html#setStringToAppend(java.lang.String)





Here you can write something like this:


"WHERE cd_molweight<500"





This only has an effect if structure caching is turned OFF.





2. JChemSearch.setFilterTable:





http://www.jchem.com/doc/api/chemaxon/jchem/db/JChemSearch.html#setFilterTable(java.lang.String)





In this case you have to put the filtered cd_id values into a temporary table.


Please note that, since JChem 2.3 this is deprecated.





Since JChem 2.3 the recommended way to achieve this functionality is to


use JChemSearch.setFilterQuery()





http://www.jchem.com/doc/api/chemaxon/jchem/db/JChemSearch.html#setFilterQuery(java.lang.String)





Here you can specify an arbitrary SQL query, which should return the


cd_id values.





Here you should specify something like this:


"SELECT cd_id FROM " + tableName + " WHERE cd_molweight<500"





This works in both cached and non-cached mode.