User 979012b3b3
04-09-2007 10:22:39
Hi,
I'm using
chemaxon.formats.MolImporter,
chemaxon.struc.Molecule,chemaxon.formats.*,
chemaxon.util.*
for designing smiles in web.
But I not obtain any image when in my smiles I have "#".
This is my code:
....
// Setting content type
String type = format.indexOf(":") == -1 ?
format : format.substring(0, format.indexOf(":"));
response.setContentType("image/" + type);
Molecule mol = null;
if(molstring == null) {
File f = new File(filename);
MolImporter mi = new MolImporter(f,"");
mol = mi.read();
} else {
mol = MolImporter.importMol(molstring);
}
if(mol.getDim()==0) {
mol.clean(2, "O1");
}
byte[] b = mol.toBinFormat(format);
ServletOutputStream outs = response.getOutputStream();
outs.flush();
outs.write(b,0,b.length);
outs.close();
....
I'm using an old version of your jar?
Thanks,Cristina
User 979012b3b3
06-09-2007 09:50:56
Any information?
thanks,Cristina
User f359e526a1
06-09-2007 10:14:10
Sorry for the late answer, could you please let me know what sort of SMILES is failing? Is it a particular structure or fails for any string containing # ? What is the value of the "format" string in the code? Marvin/MolConverter should read triple bonds without any problem.
User 979012b3b3
06-09-2007 10:19:50
Hi,
1)no work for smiles like 'C#C'(sorry but I can not post the smiles!)
2)all smiles with # in the string
3)it's a parameter, generally format=jpeg
Thanks, Cristina
User f359e526a1
06-09-2007 10:46:33
Hello, I can see you are following the example we provided, still there must be some mix up of strings. I wrote a simple non-jsp example (see attachment) where you can see that the generated image has triple bonds. Is there a way to show the (stripped down but still working) JSP page as an attachment as we are not able to reproduce the error.
User 979012b3b3
06-09-2007 11:02:12
hi,
probably my code is terrible wrong! I have inserted your smiles:
C#CCC#Cc1ccccc1C#C" in my molstring parameter.
I don't obtain a structure but a sort of image ... see attachment ... probably I have to change jar? ?? Or I have not understood ... sorry
thanks,Cristina
User 979012b3b3
06-09-2007 11:12:18
Sorry again, I have copy your java class in my project... it's ok i see the trible bonds... probably I use wrong code in my jsp but I don't understand what is wrong!
Thanks,Cristina
User f359e526a1
06-09-2007 12:48:49
Hello, I am happy it works now. There are JSP and applet samples bundled with the distribution and also on our site to help:
http://www.chemaxon.com/marvin/examples/index.html
Still, if you have any questions please write it on the forum - usually we are faster in answering.
User 979012b3b3
06-09-2007 14:32:30
No... it's not worked now... it'ok in your class but not in my jsp...
Cristina
User 979012b3b3
06-09-2007 14:54:09
Hi,
I have find the problem in jsp:
if I write in my code:
myMol="C#CCC#Cc1ccccc1C#C" it's ok and I obtain my structure as jpeg.
If I send C#CCC#Cc1ccccc1C#C as a get parameter in web browser it doesnt' work .
es:
...viewstructure.jsp?mol=C#CCC#Cc1ccccc1C#C
Cristina
User 5e8d4b0dd3
07-09-2007 03:52:40
...you need to pass the SMILES string encoded. For example, in your JSP you might have a link like
Code: |
<a href="viewstructure.jsp?mol=<%=SMILES%>">Click</a>"
|
(sorry if syntax is wrong)
The SMILES variable needs to be URL encoded, otherwise it will be chopped off before the first occurrence of the #, e.g. C#CCC#Cc1ccccc1C#C becomes C, i.e. methane as you saw!
Code: |
<%@page import="java.net.URLEncoder"%>
.
.
<%
String encsmiles = java.net.URLEncoder.encode(SMILES);
%>
.
.
<a href="viewstructure.jsp?mol=<%=encsmiles%>">Click</a>
|
KR,
Gaspode
User 5e8d4b0dd3
07-09-2007 03:54:33
...and by the way, please say "Hello" to Cesare for me!