File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes call java function from onclick Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "call java function from onclick" Watch "call java function from onclick" New topic
Author

call java function from onclick

Krishna MK
Greenhorn

Joined: Dec 05, 2008
Posts: 3
hi,

Can you please tell me how to call a java function from an onclick.Syntax or sample code is appreciated.

I have an HREF in my jsp it redirects the page i want to do some more stuff in server side along with the redirect.thats the reason to call a java function (java function is in JSP).

Regards
KG
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2712
    
    5

"KG MK " please check your private messages for an important administrative matter. You can see them by clicking the My Private Messages link above.


SCJP, SCWCD.
|Asking Good Questions|
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2712
    
    5

I have an HREF in my jsp it redirects the page i want to do some more stuff in server side along with the redirect.

I am not getting what you are trying to do exactly. Can you please elaborate .

And welcome to Javaranch
Krishna MK
Greenhorn

Joined: Dec 05, 2008
Posts: 3
hi

thanks for the reply

a href ="check" onclick???

public void fun()
{
}

I would like to call this function fun() from onclick .(fun() not being a javascript function ) could you please let me know hoe to make this call

Regards
Krishna
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Originally posted by Krishna MK:
fun() not being a javascript function


directly you can not . i guess ajax may help you
Krishna MK
Greenhorn

Joined: Dec 05, 2008
Posts: 3
Hi

Could you let me know the other ways through which i can achieve this?

Regards
Krishna
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2712
    
    5

Krishna MK check your private messages again.
And I would like to know what you want to achieve by writing such code, maybe there's another better workaround.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60057
    
  65

Please read this article to understand why what you are asking is impossible.

You will need to submit to the server, or use Ajax or an Ajax library.

And pay heed to Amit's messages. Before you post again.
[ December 05, 2008: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: call java function from onclick
 
Similar Threads
Calling DLL function
Calling .js file from Java
jsp and javascript
JOptionPane No X11 DISPLAY error
do i have to submit all the time