Coding and Invoking a Method
<%-- Here's a variable and method declaration --%> <%! int toInteger = 100 ; int sumOfFirstIntegers = addIntegers( 100 ) ; public int addIntegers( int to ) { return to * (to + 1) / 2 ; }%>
The sum of integers from 1 to <%= toInteger %> is: <%= sumOfFirstIntegers %>