• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Which would be better - Session Attribute or Session Bean  RSS feed

 
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a number of basic pieces of information regarding each user that logs into my system:

fname (user's firstname)
lang (id of the language they want to view the page in)
email (obvious)
log_time (date/time logged in)

I can't find any clear answer to this (maybe there isn't one), which is better to use, a Session Bean (standard java not EJB) which holds the get/set methods for eahc of the above and I call the methods accordingly or simply using session.setAttribute/session.getAttribute to store the values in the Browser sessiona nd retrieve them when eeded.

The lang value will be required for every page because when the user opens a page, the lang value (for example: en) will go away and get a en.properties file and populate tags on a page with text (en the page is in English, jp it's in japanese)

Cheers
KS
 
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would create a class to store all the info about the user and put the objects in session.
 
Ranch Hand
Posts: 457
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's a matter of style, but as Manuel suggested, the typical and expected solution would be to implement a class to do it.

If getter/setter methods are provided for all, then by definition it's a java bean.

if you're archiving it using hibernate or EJB, it would be annotated with @Entity in EJB 3, and you would deploy it to an application server
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!