File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes how can i restrict a servlet to create only one object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "how can i restrict a servlet to create only one object" Watch "how can i restrict a servlet to create only one object" New topic
Author

how can i restrict a servlet to create only one object

pankajjj jain
Greenhorn

Joined: Oct 12, 2005
Posts: 14
how can i restrict a servlet to create only one object
through synchronize i can restrict to use only one object but
i want to create only one
David Ulicny
Ranch Hand

Joined: Aug 04, 2004
Posts: 724
Implemet the object as singleton, this will allow only one instance of this object.


SCJP<br />SCWCD <br />ICSD(286)<br />MCP 70-216
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Originally posted by pankajjj jain:
how can i restrict a servlet to create only one object
through synchronize i can restrict to use only one object but
i want to create only one


I agree to David.
By the way, one object of what?
Chetan Parekh
Ranch Hand

Joined: Sep 16, 2004
Posts: 3636
What functionality you want to achieve by this singleton Servlet?


My blood is tested +ve for Java.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61601
    
  67

Moved to the Servlets forum.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Eddy Lee Sin Ti
Ranch Hand

Joined: Oct 06, 2005
Posts: 135
Using classical singleton pattern in J2EE environment is not a good idea. It's a pain in the ass when the "singleton" might not be singleton as you might expected. One such situation might be when there exists a hierarchy of classloaders in different J2EE modules where each might load their own "singleton". You might face problem also when in distributable web application.

If you need to ensure real "singleton" object in your environment, an entity bean would do the trick.


SCJP, SCWCD, SCJWS, IBM 700,IBM 701, IBM 704, IBM 705, CA Clarity Technical<br /> <br /><a href="http://eddyleesinti.blogspot.com" target="_blank" rel="nofollow">http://eddyleesinti.blogspot.com</a>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how can i restrict a servlet to create only one object