Call Java Method from javascript

B

BigZero

Hello,

can i call Java method that is java code from javascript,here what i m
looking for i have class called DB in this class all the DB related
things ,like DB connection DB insert,DB read etc Methods are defined.

"All i m looking for just call the DB method from javascript that Read
data from DB"
is there any way that i can do this work.("not with Applet.")


Thanks
VM
 
D

Dave Miller

Sabine said:
You can use AJAX with JSP/servlets, probably. For more on AJAX, post
to/research comp.lang.javascript
JavaScript is running on the client, Java (absent an applet) is running
on the server. If you want data to be available to the js onload use a
jsp to get the data from the DB and print ithe data to the page with the
js like var v = <%out.print(data_from_db);%>

To access the data after the page is loaded, have the js pass the
parameters to a servlet or jsp (Java), have the Java query the DB for
the data and then reload the page as above.
 
M

Mark Space

BigZero said:
Hello,

can i call Java method that is java code from javascript,here what i m
looking for i have class called DB in this class all the DB related
things ,like DB connection DB insert,DB read etc Methods are defined.

Basically, no. You can't and you don't want to, it's a bad idea.

For how to do this correctly:

<http://www.javapassion.com/ajaxcodecamp/>

Javapassion.com web site has an excellent introduction to AJAX and also
an introduction to several libraries/toolkits/frameworks that you can
use. There are step-by-step instructions for getting each framework
running and how to use it (in a simple page) plus some good explanation
of what goes on under the hood.
 
A

Arne Vajhøj

BigZero said:
can i call Java method that is java code from javascript,here what i m
looking for i have class called DB in this class all the DB related
things ,like DB connection DB insert,DB read etc Methods are defined.

"All i m looking for just call the DB method from javascript that Read
data from DB"
is there any way that i can do this work.("not with Applet.")

You can do:

Client | Network | Server
JavaScript--(call)--Java Applet-----(JDBC over TCP/IP)-----database

or:

Client | Network | Server
JavaScript-----(HTTP)-----Server side script--(DB API)--database

The server side script can obviously be done using Java servlet/JSP.

Or it can be done using any other technologu (ASP.NET, PHP,
Perl CGI etc.).

The last technique is in most forms called AJAX in todays
terminology.

Arne
 
B

BigZero

Thanks for every one

i m thinking to move to "AJAX" let c what it has in it.





Thanks
VM
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top