File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes Accessing JavaMethod from javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Accessing JavaMethod from javascript" Watch "Accessing JavaMethod from javascript" New topic
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: 60046
    
  65

"tripod tech", please check your private messages for an important matter.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60046
    
  65

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: 39541
    
  27
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.


Ping & DNS - updated with new look and Ping home screen widget
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: 60046
    
  65

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Accessing JavaMethod from javascript
 
Similar Threads
Session destroy on window close
calling bean from inside javascript function
calling a method
How to capture close[X] function in javascript?
How and Where to buy the assignment for SCEA Part 2