• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to mantain client state

 
Oscar Perez
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm developing a pure XML client-server application (not web application)
My frontend is a servlet but I can't use HttpSession (not cookies, hidden fields because my clients not are web browsers)
I need to maintain state between my clients and my server.
I need to deploy application in an cluster environment

1) Is a good solution to use Stateful EJBs and pass EJB handle back to client in every call (using it as my user sessionid)

Any help will be appreciated!
 
Frank Verbruggen
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why don't u allow a session ID to be passed along with the rest of the information in the XML messages?

Greetings


Frank Verbruggen
 
Oscar Perez
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Session id can't be used because my clients not are web browsers that mantain state automatically with my server (using coockies or url rewriting)

My clients only send XML calls to my server.

I think, the unique way would be set a filter where parse XML and then assign a new HttpSession (create new session in first XML login call) to this client. After I can keep a hashtable with info about HttpSessionId-ClientSessionID (generated autopmatically by my application). Because remember that next call of client only contain ClientSessionID NOT HttpSessionID. (I'LL CAN NOT GET HTTPSESSION FROM CLIENT USING METHODS OF HHTPREQUEST)

I think this is not a very good solution (keep a table of relation between HttpSessionId-ClientSessionID). It seems a workarround to force use of HttpSession...)

What do you think?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A unique ID does NOT have to be a sessionId managed by the servlet container - you could manage it yourself.
Make your client state a Serializable object and write it to disk using a unique file name. Thats what I do with online exam user state. If your state object is fairly simple, this can be quite fast and has a number of advantages. For a larger number of users write the serialized object to a database.
Alternately, you could implement your client with a toolkit that emulates the cookie storage capabilities of a browser - see the HttpClient toolkit in the Jakarta Commons project. That way standard session management could be used.
Bill
 
Oscar Perez
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much William, but I have 2 inconvenients:

1) My application must be deployed in a cluster environment (so I need some kind of Session balancing or distributed applications facilities)

2) I does not control my clients (bad luck!) (my clients are arround the world) and are unknown for me... so I can't told their that must use applications that supports cookies... (they can programe in PHP, VisualBasic ...)

- Idea to store session in a file or in a DB is an option (if file can be shared by all servers of cluster), but I should discard it by performance isues. (Session in DB it's not discarded of all!)

Thank you very much for you support!
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Idea to store session in a file or in a DB is an option (if file can be shared by all servers of cluster), but I should discard it by performance isues. (Session in DB it's not discarded of all!)

You appear to be jumping to a conclusion about the performance.
Obviously, if you program your own session storage mechanism, it is up to you to provide for removing outdated data.
Bill
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!