Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Call Java Method from javascript

Reply
Thread Tools

Call Java Method from javascript

 
 
BigZero
Guest
Posts: n/a
 
      05-08-2008
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
 
Reply With Quote
 
 
 
 
Dave Miller
Guest
Posts: n/a
 
      05-08-2008
Sabine Dinis Blochberger wrote:
> BigZero wrote:
>
>> 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.")
>>

>
> 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.
--
Dave Miller
Java Web Hosting at:
http://www.cheap-jsp-hosting.com/
 
Reply With Quote
 
 
 
 
Mark Space
Guest
Posts: n/a
 
      05-08-2008
BigZero wrote:
> 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.
 
Reply With Quote
 
Arne Vajh°j
Guest
Posts: n/a
 
      05-09-2008
BigZero wrote:
> 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
 
Reply With Quote
 
BigZero
Guest
Posts: n/a
 
      05-09-2008
Thanks for every one

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





Thanks
VM
 
Reply With Quote
 
copernic777
Guest
Posts: n/a
 
      05-09-2008
Try this

http://getahead.org/dwr/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Poll: Is a Java Method an Instance of the Java Classjava.lang.reflect.Method? Please reply with YES or NO. Paka Small Java 15 02-07-2012 07:04 PM
Javascript -> Applet: variable reset after method call from javascript?! mcdeveloper Java 1 06-13-2006 08:34 AM
Call a Java method from Javascript mhust6@gmail.com Javascript 2 06-06-2006 04:08 PM
Help with a utility class and having a method call another method from within Ian Python 2 09-06-2003 03:35 PM
How to call an instance method from a static method allowing overrides? =?ISO-8859-1?Q?Thomas_Gagn=E9?= Java 9 07-02-2003 11:04 PM



Advertisments