• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

can servlets have constructor

 
maheswari kris
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
can servlets have constructor?
i know that servlets have constructor that is provided by the container

what happens if we provide the constructor?
i know that if we provide constructor, you are voilating the container rule.

i want to voilate the container rule ? what happens if we provide constructor?
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can servlets have constructor?


Servlet is a Java Class , so it has to have a constructor (either default or programmer defined ).

what happens if we provide the constructor?
i know that if we provide constructor, you are voilating the container rule.

i want to voilate the container rule ? what happens if we provide constructor?
[jumpingjoy] [jumpingjoy]


Why don't you try this and tell us what container says !
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64832
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by maheswari kris:
i know that servlets have constructor that is provided by the container
No, it doesn't. Servlets are java classes like any other and just like any other class, if you do not provide a constructor, a default constructor is created. It has nothing to do with the container.
[ July 30, 2008: Message edited by: Bear Bibeault ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64832
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, please be sure to check the Servlets FAQ before posting to see if your question, like this one, has already been addressed.
[ July 30, 2008: Message edited by: Bear Bibeault ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic