Author
Accessing JavaMethod from javascript
Rahul Sinha
Greenhorn
Joined: Sep 10, 2008
Posts: 3
Is there a way to Accessing JavaMethod from Javascript on a jsp page <body onunload="doUnload()"> function doUnload() { alert("Window is closed...!"); Class1.ClearObject(); } I am able to get the alert but am not able to access the ClearObject method inside static class Class1 Any help/hint is appreciated
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56204
"tripod tech", please check your private messages for an important matter.
[Smart Questions ] [JSP FAQ ] [Books by Bear ] [Bear's FrontMan ] [About Bear ]
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56204
No. That's what you need Ajax for.
Rahul Sinha
Greenhorn
Joined: Sep 10, 2008
Posts: 3
Originally posted by Bear Bibeault: No. That's what you need Ajax for.
Can you guide me through the process
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35252
posted Sep 10, 2008 15:59:00
0
Should this Java method run on the server or on the client? If the former, AJAX is -as Bear mentioned- your best bet. If the latter, you could embed an applet in the page that runs the method for you. That'd be a hack, though, with a number of drawbacks.
Android apps – ImageJ plugins – Java web charts
Rahul Sinha
Greenhorn
Joined: Sep 10, 2008
Posts: 3
Originally posted by Ulf Dittmer: Should this Java method run on the server or on the client?
It would be running on the client but there's no applet used..could you guide me on the steps using ajax to make the java call
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56204
Ajax would be used to communicate back to the server. If the Java code is to run on the client, you'll need to use an applet.
subject: Accessing JavaMethod from javascript