File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using sessions in a web / non-web environment

 
Ruben Matthews
Greenhorn
Posts: 26
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!

I am creating a content repository system in Java that should be able to serve either web or desktop applications. And now I want to create some kind of session management, but I can't use cookies, since the system is not strictly for use in a web environment. How would you retain session (credentials/login) information in this situation? Should I store sessions myself in a db? And if so, how would I retain the link between the stored session and the client?

Thanks
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I normally wouldn't store sessions in the DB, I'd keep them on the app server (or whatever kind of server it is that runs the repository system). A session is really just a glorified Map for each user. Assuming that there are persistent socket connections for each client, the server would effectively keep a Map<Socket, Map<String,Object>> where all session maps are stored with the socket as the key to retrieve them.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean by a "non-web environment"? If the user is running an app there's no reason to keep session information--it's not a series of disconnected HTTP requests.

If you're actually talking about a desktop application using a web service, then it's still a web environment, just hidden: either use cookies, or get a session ID in the login response and use it in subsequence requests.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic