• Post Reply Bookmark Topic Watch Topic
  • New Topic

Set up a Class to hold Global Values  RSS feed

 
Steve Dyke
Ranch Hand
Posts: 1783
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can someone help me to set up a class UserInfo to hold several values(record field data such as First Name, Last Name, Password) which I get into a results table when the user logs on. Then I need these values accessible in the rest on my app(Servlets, JSP's, other classes.
 
Roseanne Zhang
Ranch Hand
Posts: 1953
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It smells not a good design...

Please restrain yourself by not doing it, unless your boss force you to do so...
 
Steve Dyke
Ranch Hand
Posts: 1783
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you recommend another approach?
 
Roseanne Zhang
Ranch Hand
Posts: 1953
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can set a session attribute to hold current user information.
 
Steve Dyke
Ranch Hand
Posts: 1783
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok. I am sorry, but can you elaberate.
 
Roseanne Zhang
Ranch Hand
Posts: 1953
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because you mentioned JSP/servlet, I assume it is a web application. What I told you is one general approach in web application.

You need to read a basic book or web tutorial to learn the basic concepts.

How about start from here:

http://www.jsptut.com/

It does has a session section.

-- disclaimer, I did not read it, and it cames from a google search
 
Anupam Sinha
Ranch Hand
Posts: 1090
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[RZ:]It smells not a good design...

Please restrain yourself by not doing it, unless your boss force you to do so...


Can you please elaborate what's wrong with the design. Apart from the fact that the password also gets saved in the userInfo Data Object.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!