How to access the session from a Java class

griegs picture griegs · Sep 20, 2010 · Viewed 28.5k times · Source

I need to write a small Java class that will enable me to add to and read from the current user session.

Everything I see refers to Servlets but I'd ideally like to just use a plain old class.

Can anyone please help this Java Newbie?

Thanks

Answer

Sam Day picture Sam Day · Sep 20, 2010

The general concept of a "Session" is really just a data storage for an interaction between a HTTP client and server. Session management is automatically handled by all HTTP Servlets. What framework?

If you're just wanting to store information for a console app to remember information between runs, then consider using Xml to save/load data from a file.