File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes javascript/jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "javascript/jsp" Watch "javascript/jsp" New topic
Author

javascript/jsp

Peter Guillebaud
Ranch Hand

Joined: Jul 11, 2001
Posts: 57
is it possible to get a javascript onClick() event to fire a sql query from my jsp page?
Gurpreet Sachdeva
Ranch Hand

Joined: Feb 20, 2001
Posts: 90
Hello Peter,
First I would say why you want to use JavaScript, why not jsp at both pages.
Okay, here is your solution........
HTML file using java script.

JSP file for firing SQL query.

This is just a sample code.You can modify it according to your requirment.
------------------
Regards
Gurpreet Sachdeva
For Mock Exams, FAQ, Exam tips and some useful information about Bitshift operator, inner classes, garbage collection,etc please visit: http://www.go4java.lookscool.com
[This message has been edited by Gurpreet Sachdeva (edited October 26, 2001).]


Regards<BR>Gurpreet Sachdeva<P>For Mock Exams, FAQ, Exam tips and some useful information about Bitshift operator, inner classes, garbage collection,etc please visit: <A HREF="http://www.go4java.lookscool.com" TARGET=_blank rel="nofollow">http://www.go4java.lookscool.com</A>
Peter Guillebaud
Ranch Hand

Joined: Jul 11, 2001
Posts: 57
Thanks Gurpreet,
What I am trying to do is have one html select box populated as a result of a choice from a previous select box. I want to avoid having submit buttons but to use the onChange() method of the select box. What needs to happen is when the user chooses a value from the first box, the onChange() event on the client side somehow fires a sql query which populates the second box according to the choice in the first. Any ideas welcome!
TIA
[This message has been edited by Peter Guillebaud (edited October 29, 2001).]
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

Well, just remember that javascript is 100% client-side, and JSP code is 100% server-side.

There is really no way to get JSP code to run, and return to the 'same' page on the client side. You'll need a re-load of some sort. You *can* use javascript to submit the page to your server-side code, be it a JSP (and of course, you can submit the page to itself) or servlet. The server-side will know which value in the first select box has been selected, and when it is finished, it will re-display with both select boxes full of values.
Peter Guillebaud
Ranch Hand

Joined: Jul 11, 2001
Posts: 57
thanks Mike, I used javascript to resubmit the jsp page to itself when the onchange() event was fired in the select box, and then jsp to do the sql query. Thanks for your help!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: javascript/jsp