aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes invoking java function with java script Onclick event Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "invoking java function with java script Onclick event" Watch "invoking java function with java script Onclick event" New topic
Author

invoking java function with java script Onclick event

AmitKashyap kashyap
Greenhorn

Joined: Mar 16, 2005
Posts: 5
Hi All,

Is it possible to invoke java fucntion in JSP through java script OnClick event.
I am able to invoke javascript function through OnClick event but not able to do the same with java function.

Thanks in Advance,
Amit
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61648
    
  67

No, it is not possible.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Kedar Dravid
Ranch Hand

Joined: May 28, 2004
Posts: 333
But then, you can always call the Java function by:
1) importing the necessary Java class inside your JSP.
2) Calling the Java function from within a scriptlet which you can place inside a Javascript function which is invoked on the onClick event.
The net result is the same as invoking a Java function from an onClick event.
Chit Ming Chong
Ranch Hand

Joined: Sep 09, 2004
Posts: 49
to put it more simply, just do a onClick submit form
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61648
    
  67

Calling the Java function from within a scriptlet which you can place inside a Javascript function which is invoked on the onClick event.
The net result is the same as invoking a Java function from an onClick event.


Not so!

The JSP is executed on the server long long before the resulting response is sent back to the client. The embedded Java call is executed as the page is being constructed and in no way can be invoked as a part of the onclick handler.

"Embedding" a Java function in a JS function only serves to "write" the results of the Java function to the body of the JS function. Which is not even remotely the same thing as "calling" the Java function as part of the JS function.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: invoking java function with java script Onclick event