• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 354
  • Last Modified:

javascript in JSP

Hi  ,
I m  working on Javascript with JSP .
I wud like to call Javascript function in JSP .
ex:
<script language="javascript">
java script function(abc) goes here
</script>

xyz.jsp

if (true) // then
{
//here i wana call Javascript function (abc) written above
}
thx and rgds
0
sreddy_k
Asked:
sreddy_k
1 Solution
 
dasmaerCommented:
you can't call in per say, but you could print out:
<script>function(<%=abc%>)</script>
to the page and it would pass abc to your javascript function.
0
 
dasmaerCommented:
so a more complete example is:
<script>
function my_fuction(var str){
  //do stuff
}
</script>

<%
  if(true){
    %>
      <script>my_function(<%=abc%>)</script>
    <%
  }
%>
0
 
sreddy_kAuthor Commented:
Hi dasmaer
Thx for u r immidiate responce ..
i have tried it doing in the same way earlier but it dint work .. i m just copying and pasting my stuff here ..
xyz.jsp
<%import ...............%>
<script>
fucntion disb()
{
here i m disabling text field
}
}
</script>
<% boolean trorfa = getting some value%>
<%
if(trorfa)
{%>

<script> disb</script>

<%}%>
its not working .
Thx n regds





0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
dasmaerCommented:
how about this:
<script>
    return disb();
</script>

0
 
sreddy_kAuthor Commented:
Thx for u r reply dasmaer ..
i have tried it but no result ..
rgds
0
 
deeppraCommented:
what error u r getting
0
 
PrasathAnnamalaiCommented:
Javascript runs on the client, JSP runs on the server. They cannot
communicate with each other directly.
0
 
sreddy_kAuthor Commented:
Hi ,
I am new to webservices in java  and could some one pls let me know how can i use them in my project
?? I would also like to know the best use of Web Services in real world .it  would be great if some one give me an example . pls also refer some best site for reading and deeloping web services.
Thx and Regards
 
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now