Mike McElligott wrote:
>2. Can I define a function in jsp? I don't see any reference to doing so
>in the spec. I'm aware that this is the 'wrong' way to do stuff and that I
>should do my logic in a bean, but I want to know if it's possible. It
>seems
>like something that, even if it isn't in the spec, will probably be
>implemented by vendors who want to compete with the versatility of...ahh..
>other scripting environments.
Sure, you can define a method in a declaration. It will become a
method of the page implementation class, so you can call it from any
other scripting elements on the page.
For example:
<html>
<body>
Fact(4) = <%= fact(4) %><br>
Fact(5) = <%= fact(5) %><br>
Fact(6) = <%= fact(6) %><br>
<%! public long fact (long x) {
if (x == 0) { return 1; }
else return (x * fact(x-1));
} %>
</body>
</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