This week's book giveaway is in the Testing forum.
We're giving away four copies of Practical Unit Testing with TestNG and Mockito and have Tomek Kaczanowski on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes javascript database connectivity Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Practical Unit Testing with TestNG and Mockito this week in the Testing forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "javascript database connectivity" Watch "javascript database connectivity" New topic
Author

javascript database connectivity

Rene Curth
Greenhorn

Joined: May 13, 2004
Posts: 11
Hi there,
I have to deal with a little problem. In a Combo-Box are displayed a lot of last names, ready for selection. Nearby is an text input field, which is waiting for user entry (also a last name). The javascript function has to detect user action in this input field (e.g. onkeypress) and to update the combobox with names beginning with the characters, displayed in the input field while he (or she) is typing it. The names are stored in a ms sql-server database (more than 7000).
The updating process has to be dynamically. My solution up to this point was to integrate an applet, which contains a swing combo-box. The applet is accessed by an javascript function (onkeypress) and contacts a servlet, doing the sql-job. The servlet returns the result to the applet, which is updating the combo-box. Also it's updating other input text-fields (first name, birthdate) by talking to another javascript function.
I think this solution is very complicated and not very elegant. Is there another way for an javascript function to talk with a server-sided database directly or to put it in other words: is there a way for a javascript function to communicate with a servlet directly?
What about jsp? Is it possible to put jsp-code in a javascript function, doing the job dynamically?
I would appreciate a more elegant way of doing it!
Thanx in advance
Rene
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
You can NOT execute serverside code from Javascript (or any other clientside technology).

In your javascript, you'll need to call a servlet to generate the data which you can then insert into a span or div (or you need to regenerate the entire page from scratch).


42
 
 
subject: javascript database connectivity
 
Threads others viewed
Need help in dynamic forms
Html text returns null if disabled="true"
Servlet getting values from a combo box
Flex Combobox and Grid loads very very slowly for large data
How to iterate using struts 2 ?
IntelliJ Java IDE