• Post Reply Bookmark Topic Watch Topic
  • New Topic

How can I maintain state in JAXRPC

 
yang lu
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using WSAD, Thanks!
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The short answer is "you don't". Web Services are supposed to be stateless. There are ways of doing it in JAX-RPC, but I would STRONGLY discourage you from doing it because you're violating a primary tenet of Web Services and will be complicating your architecture significantly.
Kyle
 
yang lu
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your prompt reply. Keeping a stateless web services definitely makes my application simple and efficient. But I have a series of transactions, if I dont maintain a state, which means I need prompt the client to pass me user_id and password for each of the transaction. Are there any other smarter ways?
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If it's just userid and password you need then pass them in the HTTP header as is supported by JAX-RPC. That's not really application state -- it's something separate.
Kyle
 
yang lu
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, kyle. If I can maintain a state, I dont need ask the client to pass me the userid/password for the next several transactions after it provides me at the first time(like online shopping or even this forum system). I may also keep the client's profile somewhere instead of retriveing it again and again from other places.
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
*Sigh* I'm telling you this is a BAD idea... and that you should consider not using Web Services in this way... but, if you insist, take a look at section 13.2 of the JAX-RPC spec and also section 10 of the JAX-RPC spec. In particular, if you obtain the ServletEndpointContext the getHttpSession() method will allow you access to the HttpSession...
Kyle
 
yang lu
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, Kyle!
Yang
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!