Results 1 to 5 of 5
Thread: call a JSP method
- 03-25-2010, 06:38 AM #1
Member
- Join Date
- Mar 2010
- Posts
- 10
- Rep Power
- 0
- 03-25-2010, 08:45 AM #2
See this below sample code for calling jsp meth in javascript.
<%!
String hai()
{
return "Iam Ramya";
}
%>
<HTML>
<HEAD><TITLE> Example of onClick Event Handler</TITLE>
<SCRIPT LANGUAGE="JavaScript">
function callJsp(){
alert("<%= hai()%>");
}
</SCRIPT>
</HEAD>
<BODY BGCOLOR="FFFFFF" TEXT="000000">
<form name="myform">
<INPUT TYPE="button" VALUE="Click Here" onClick="callJsp()">
</form>
</BODY>
</HTML>Ramya:cool:
- 03-25-2010, 10:08 AM #3
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Except, of course, that method is not actually being called in the Javascript.
It's being called on the server when the JSP is run, which puts a value into that place, which is then used by the Javascript on the client.
Very different to it actually being called by the Javascript.
In short, you can't. JSP code runs on the server, and Javascript on the client.
You can make calls to the server to do stuff, but I doubt that's what you want.
- 09-26-2011, 04:11 PM #4
Member
- Join Date
- Sep 2011
- Posts
- 1
- Rep Power
- 0
Re: call a JSP method
- 09-26-2011, 04:19 PM #5
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Similar Threads
-
how to call method?
By leapinlizard in forum New To JavaReplies: 9Last Post: 04-29-2009, 11:55 PM -
How to call a class within a method
By Manfizy in forum New To JavaReplies: 3Last Post: 03-19-2009, 12:34 PM -
Call java method from jsp
By saiphani723 in forum JavaServer Pages (JSP) and JSTLReplies: 0Last Post: 02-25-2009, 11:21 AM -
How to call method in servet by using JSP?
By frankjava1 in forum Java ServletReplies: 2Last Post: 10-24-2008, 04:20 AM -
cannot call private method from static method
By jon80 in forum New To JavaReplies: 3Last Post: 05-07-2008, 08:37 AM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks