This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to create an HttpSession in a non-servlet class

 
Thirumaran Somasundaram
Greenhorn
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can we create a HttpSession without a servlet....i mean, an ordinary java class with http session....how do we create this...does any one knows or have a sample coding for it.....please let me know.....
Thanks
 
Michael Morris
Ranch Hand
Posts: 3451
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Thiru,
Welcome to JavaRanch, the absolute best site on the www for Java information. We don't have many rules around here, but we do have one. Please change your display name to a first and last name to comply with the JavaRanch Naming Policy. You can change it here. Thank you for your cooperation.

Why in the world would you want to create a HttpSession object outside a web container? But if you really want to do it, just create a class that implements HttpSession.
 
Van Glass
Ranch Hand
Posts: 110
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are you trying to accomplish? Perhaps with some more information I may be able to point you in the right direction.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33694
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use a mock session object. The mock objects website gives you one without having to write any code. It can do almost anything a real session object can do. The mock object is intended to be used for testing.
If your session object is used in real code, you may want to consider changing the interface. It's better to keep the presentation layer separate.
mock objects
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne, that interests me a lot. Two follow-ups: Your link needs an "s" to become http://www.mockobjects.com. And I couldn't find anything on session there. Maybe it didn't need an "s" and I went the wrong place altogether?
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic