jsp example displays all records when no query specified.

User f875cff0a8

12-05-2011 06:42:54

i have successfully integrated  jsp example code  with another web application for structural search,and it works fine.

i have a small issue..

in the example when we submit null/no query,it displays all the structures from the table.but i want to throw alert

message(no query specified) to user when the query is null and it should not display all the structures from table.

 

please help me with some sample  code.

thanks in advance

sricharana

 

ChemAxon e274e1bada

12-05-2011 12:22:37

Hi Sricharana,


This what you described is the normal behaviour of JChem. If you want to check for emty structure, you should do it on JSP side.
I recommend you to put this checking in the  searching.jsp after line 88 when we read the query molecule from the session info. You can change theoutput regarding  the result of this checking. e.g. 
<jsp:forward page="myErrorPage.jsp" />


Regards, Edvard

User f875cff0a8

13-05-2011 11:24:21

hi Edvard,


we have tried this, it seems not working. Infact i am using simple_db_search code for integration. could you please suggest on this.


sricharana

User c1ce6b3d19

13-05-2011 13:11:07

sricharana,


If you are having trouble with JChem technology, please include what you think is not working.  Especially if there is JChem Base code or examples involved, you may paste the relevant parts into the forum. This will help to give you the quickest and most effective responses.


 


Jon



User f875cff0a8

14-05-2011 11:03:07

hi Jon,


In JChem it is getting all structures for empty query.but i want to display an error message for empty query.iam using simple_db_search code.iam placing the relevent code.suggest me where i have to modify the code.


-->query.jsp


javax.servlet.http.HttpSession ssn = request.getSession(true);
String molFile = (String)ssn.getAttribute(sessionVarPrefix+"query.molfile");
ssn.removeAttribute(sessionVarPrefix+"query.molfile");
if(molFile==null) {
    molFile = "";
}


-->search.jsp


String molfile = (String)request.getParameter("molfile");
if(molfile != null) {
    session.setAttribute(sessionVarPrefix+"query.molfile", molfile);
    session.setAttribute(sessionVarPrefix+"query.quantity", request.getParameter("quantity"));
    session.setAttribute(sessionVarPrefix+"query.type", request.getParameter("type"));
    session.setAttribute(sessionVarPrefix+"search.action", "starting_search");
}


 


thanks,


sricharana

User c1ce6b3d19

15-05-2011 20:02:28

sricharana,


I think Edvard is correct, you should place the checking code somewhere after reading query.molfile from the session.  Perhaps after the closing if statement, so that you only have to check for molFile being equal to the empty string ("").  It is up to you to get the code implementation to your own specification.  


As Edvard mentioned, you can use jsp forward command, or as you mentioned, use the alert box.  A word of caution, just make sure the state of the session is how you want it.


Good luck,


Jon