Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Storing objects for use in whole web app

843842Jun 21 2009 — edited Jun 21 2009
Hi all,

Hopefully the correct forum section. Firstly I would like to say that I am a student still learning Java but more in desktop developing terms. I have been trying to get into doing some web app development to get some experience on how it works etc.

To the problem... Please give me a good virtual slap if this makes no sense.

I am trying to write a simple web app using the MVC style but without any large frameworks such as spring, faces, etc to start. So basically Source -> Servlet -> JSP

What I would like to know is how best to store objects or even if storing them is the correct way in the web app. I will be using Glassfish.

Say I am trying to create a simple web login page that takes user input then checks a database for matching info. If found it creates a new user object like
User myUser = new User()
where should this object be stored for later use accessing secure pages. Any best practices?

Should the object be stored in a session, application context, or a controlling class. Or should I drop the object and just store basic information such as Strings in the session. I am trying to avoid using a database to store an object.

A controlling class sounds similar to the desktop style but seems a little different in implementation. (storing user objects in a collection)

Also if this information helps, I am not using a "god" servlet or a servlet per page. More along the lines a servlet per category so one for the entire authentication area of things and another for other parts of the web app.

Thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 19 2009
Added on Jun 21 2009
1 comment
83 views