• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Accessing JavaMethod from javascript

 
Rahul Sinha
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"tripod tech", please check your private messages for an important matter.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. That's what you need Ajax for.
 
Rahul Sinha
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bear Bibeault:
No. That's what you need Ajax for.



Can you guide me through the process
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rahul Sinha
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic