Use 1 variable in different bean/classes
As a university project I was told to develop a Hangman game.
The game itself is OK and working, but I am having some difficulties in some "extras" that I had to include. I have to display the Highest Scores and a Chat using persistent tables. Both are partially working, by that I mean, the Chat records/shows the comment and the Highest Scores records/shows the score but on both I can't show/record the name!! The name's value is always = null;
Explaining better my project:
- I have a login page which uses a LoginBean to check/validate the name and password entered. (here I have the get and set for name/password)
- From my GameBean and ChatBean I need to pass the value of the LoginBean's name to record into my tables. I am using on GameBean and ChatBean the following code to access the name on LoginBean:
And then using the variable name as parameter!!
LoginBean loginBean = new LoginBean();
name = loginBean.getName();
It doesn't appear as an error but the value on name is always NULL!! All my jsp pages shows the correct value when I refer to loginBean.getName() though!!
Why is not working? What am I doing wrong?