-----Original Message-----
From: A mailing list about Java Server Pages specification and reference
[mailto:[EMAIL PROTECTED]]On Behalf Of Veena

>can i access a javascript method within jsp...............

Simple answer is no.
JSP is server-side only, the <SCRIPT LANGUAGE="JavaScript">...</SCRIPT> tags
are client-side (browser) only.

>what i mean to say is can i do something like this..
>the code below is not working....So is there any alternative to do
this..........

The obvious answer to that is, write the functions in Java instead :-)

You can generate JavaScript code from JSP, which can be a useful technique.

One other point looking at your example, the <%! ... %> tags declare methods
and variables that are shared between all requests to the JSP page - you
need to be aware of any potential concurrency issues. In contrast variables
declared within <% ... %> get defined separately for each request.

HTH,

Steve

>code is as follows...........
>
><html>
><%! int x=10; %>
><%! int y=20; %>
><%! int z; %>
><% z=addnos(x,y) %>
><% System.out.println("the sum is :"+z); %>
>
><head>
><SCRIPT LANGUAGE="javascript">
> function addnos(var a,var b) {
> var c=a+b;
> return c;
>}
></SCRIPT>
></head>
>/html>

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html

Reply via email to