Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Servlets and the fly likes constructors... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "constructors..." Watch "constructors..." New topic
Author

constructors...

eswar kumar
Ranch Hand

Joined: Oct 20, 2002
Posts: 98
Can we use constructors in servlets?
Avi Abrami
Ranch Hand

Joined: Oct 11, 2000
Posts: 1121

Yes, as long as they have no arguments.
Good Luck,
Avi.
Mathews P Srampikal
Ranch Hand

Joined: Nov 26, 2002
Posts: 211
what is the use of constructor without arguments.....what will happen if there is an argument constructor???


Thanks,
Mathews
Varun Khanna
Ranch Hand

Joined: May 30, 2002
Posts: 1400
Originally posted by Mathews P Srampikal:
what is the use of constructor without arguments.....what will happen if there is an argument constructor???

In the earlier java specification, for the instances which were to be loaded by a class loader, the inclusion of a constructor with an arguement was not supported.And servlets were/are loaded by a class loader.
But IMO, this should hold true only in the case you have provided "only" an arguement constructor, what if you have provided a default no arguement constructor as well? as then class loader can load the instance easily.
[ November 19, 2003: Message edited by: V�r�n Kha�n� ]

- Varun
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: constructors...
 
Similar Threads
Constructors are not inhertied - True
Can constructor throw exception?
Why I can't call the parent class constructor?
another question on constructors
OOP 4: Lookup