is there a way to define enum inside jsp page ?

What are you trying to achieve?

i used a bean object like this:

<jsp:useBean id="game" class="Classes.Game" scope="session" />
 <jsp:setProperty name="game" property="*" />

in the calss Game there is a property that is an array of enum type that i defined.
i want to access the arrays values which are from the enum type.

I presume you implemented some setter and getter methods in your "Game" bean. Therefore you should be able to get them with something like game.getMyEnumArray(numPosition)

yes but i want to compare values inside array.
like this:

numPosition[i] == Enum.player1 ;

i cannot do this because the enums defenition in in Game calss
and the jsp does not recognize this kind of Enum.

in class Game i defined :

enum State
    {
      empty,player1,player2;   
    }

public class GameBoard {
    
    private final int N = 8;
    protected State[][] Board = new State[N][N];
}

i can get Board with getBoard, but i cannot compare it's values.

i imported my enum to the jsp page and it's working now.
thanks for the help.

I'm sorry, I'm short for this challenge. What I found is that Duke's Bank application uses Enum. So what I can say is just dig arount and have look on source code

PS: lol my respond just minutes behind solution

my jsp project includes class Game:

public class Game {
    
    private final int N = 8;
    public State[][] Board = new State[N][N];
    public enum State
    {
      empty,player1,player2;   
    }
}

in my jsp page i wrote :

<%@page import="Classes.Game.State" %>.
<jsp:useBean id="game" class="Classes.Game" scope="session" />
 <jsp:setProperty name="game" property="*" />

<% if (game.getBoard()[i][j-1]==State.player1) { %>
                                      <td><img src="b.JPG" heigh="40" width="40"></td>
                                      <% } %>

the if statement is working due to the import line

commented: Thank you for share solution +10
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.