Reputation: 885
I am using com.sun.net.httpserver.HttpServer as my HTTP Server with JAVA SE. Specification can be found here: http://docs.oracle.com/javase/6/docs/jre/api/net/httpserver/spec/com/sun/net/httpserver/package-summary.html
I need to keep some basic data into my session and since there is no HttpSession object here, I need to create my own. But I need to keep it as simple as possible (as always).
Any tips would be appreciated, even short ones. My source code is available at: https://github.com/fidelio-coder/HttpServer
Upvotes: 1
Views: 1363
Reputation: 109547
If you did something with JSF, you saw that variables can be in different scopes: application, session, request, and custom (your own kind of map). So for a clean design the session variables belong to a more general class, than merely the HttpSession.
As already said, using sun classes might lead to some pitfalls, especially when switching from local development under Windows to deployment under Linux (which often uses the OpenJDK).
There cannot be said much more about HttpSession, besides the API.
Though you want to do all thing yourself, I had to think of Apache Shiro, that provides security, sessions and such. Sessions between local Java SE applications and Java EE server! It might be worth looking into their ideas/APIs.
Upvotes: 3