Win a copy of Transfer Learning for Natural Language Processing (MEAP) this week in the Artificial Intelligence and Machine Learning forum!
  • 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 ...
  • Campbell Ritchie
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • salvin francis
  • Carey Brown
  • Frits Walraven

putting functions in session objects.advisable?

Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have this servlet where as it be used as a session object to store logged in member info.

<jsp:useBean id="MEMBER" scope="session" class="my.member" />

sample contents of servlet:

since each logged in user will have it's own MEMBER session object spawned, I wonder whether it's advisable or not putting functions inside it or should I isolate those functions in another servlet altogether? (like below, perhaps).

author & internet detective
Posts: 39957
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Java compiler won't store a copy of the function in the session. Having menthods on your object will not make the session larger.

So you should do what is clearer. In this case, it looks like adding some methods to the Member object would be clearer than keeping them in the Servlet.
No matter. Try again. Fail again. Fail better. This time, do it with this tiny ad:
Two software engineers solve most of the world's problems in one K&R sized book
    Bookmark Topic Watch Topic
  • New Topic