Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

can we declare private constructor in servlet

 
rehans oberoi
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
can we declare private constructore in servlet , what would
be the answer.

thanks
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can, but there would be little point since it would not be called by the container when loading the Servlet, and in doing so you may prevent the no-arg constructor from being called and stop the Servlet from being initialised at all.

The short answer is: not in any meaningful sense, no.
 
rehans oberoi
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
recently this question was asked in two interviews.
how can i convince them by saying no.
[ February 19, 2006: Message edited by: rehans oberoi ]
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well you don't convince them, you provide reasoning. If you need more information, we have discussed constructors in servlets a few times, such as here.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic