Rikkin
Rikkin

Reputation: 509

Using Beans in JSP

I'm coding a program in java that take a few information from a graph (X axis and Y axis), and then I need to take this information and pass to a JSP page.

this is the java

package view;

public class Axis{
       double[] axisX;
       double[] axisY;
       int test;

       public Axis(){
       }

       public void setAxisX(double[] axisX){
           this.axisX = axisX;
       }

       public void setAxisY(double[] axisY){
           this.axisY = axisY;
       }

       public double[] getAxisX(){
           return axisX;
       }

       public double[] getAxisY(){
           return axisY;
       }
}

Then in the JSP is this what I have to do?

<jsp:useBean id="view" class="view.Axis" scope="session"/>
Test: <%= view.getAxisX() %>

Upvotes: 0

Views: 155

Answers (1)

AllTooSir
AllTooSir

Reputation: 49432

What you are basically trying to do is use Standard Actions :

<jsp:useBean id="view" class="view.Axis" scope="session"/>
<br> X :<jsp:getProperty name="view" property="axisX" />
<br> Y :<jsp:getProperty name="view" property="axisY" />

You can use EL/JSTL for this instead of Standard Actions.

Also read ,

How to avoid Java Code in JSP-Files?

Upvotes: 3

Related Questions