This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
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


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
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: 2716
    
    6

"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: 2716
    
    6

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: 2716
    
    6

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: 61082
    
  66

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