Hi,
 
I would like to calculate the factorial of a number via XSP. The number should be transmitted as a parameter via HTTP.
 
The code I've got for this purpose is the following: it retrieves the parameter 'number' and defines a fac method, that calculates the factorial of its formal parameter.
My problem: I don't know the syntax to calculate the fac() for the parameter 'number'. For the moment, I'm just able to calculate fac(8) or fac(13), and it runs well; but itsn't exactly what I want...
 

<?xml version="1.0" encoding="iso-8859-1"?>

<xsp:page language="java"

xmlns:xsp="http://apache.org/xsp"

xmlns:xsp-request="http://apache.org/xsp/request/2.0">

<xsp:logic>

public static long fac(long n) {

if (n>1) return (fac(n-1)*n);

else return 1;

}

</xsp:logic>

<document>

<para>

<xsp-request:get-parameter name="number" default="Not provided"/>

</para>

 

<factorial-calcul>result: <xsp:expr>fac(8)</xsp:expr></factorial-calcul>

</document>

</xsp:page>

 

I would be very grateful for any assistance,

Thanks,

Cyril.

Reply via email to