In this example, A component is built that can perform statistical calculations on a series of numbers. The numbers themselves are stored in a single, indexed property. Other properties of Bean hold the value of statistical calculations, like the average or the sum.

JSP Bean tags deal exclusively with scalar properties, the only way to interact with indexed properties such as these is through JSP scriptlets in the body of the <jsp:useBean> tag to pass an array of integers to the Bean’s numbers property.

<jsp:useBean id="stat" class="DemoStatBean">
  double[] mynums = {100,200,300,400,500)
The average of 
  double[] numbers = stat.getNumbers();
  for(int i=0;i<numbers;i++){
  out.println("" + numbers[i]);
is equal to <jsp:getProperty name = "stat" property ="average"/>

import java.util.*;
public class DemoStatBean {
  public double[] numbers;  
  public DemoStatBean(){
    numbers = new double[0];
  public double getAverage(){
    double sum = this.getSum();
      return 0;
      return sum/numbers.length;
  private double getSum() {
    double sum = 0;
    for(int i=0; i<numbers.length;i++){
    return sum;
  public double[] getNumbers() {
    return numbers;
  public void setNumbers(double[] numbers) {
    this.numbers = numbers;
  public double getNumbers(int index){
    return numbers[index];
  public void setNumbers(int index,double value){