I am having a slight problem in my JSP project. Basically, my project is a two-player game over the Internet. There are two bean classes - Player and Game. Now, I want these two players to use the same Game object. The problem is: the name of the Game object cannot be hard-coded into the JSP code. So, for example, there will be a auto-generated name for the Game object such as game123, and I want the JSP document to create an instance of Game by:
Game game123 = new Game();
However, I cannot hard-code it this way, because the next game to be shared by two players will be called game124.
Intuitively, I thought the answer would be to store the name of the Game object in a String and then use it to create the object. But does anyone know if Java allows objects to get their names from String variables?
If that is not possible, has anyone faced such a problem before and know a way to get around this? I am open to any sort of idea, because I really need a way to get around this.
We're pleased to have you here with us on the Ranch, but there are a few rules that need to be followed, and one is that proper names are required. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.
In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.