aspose file tools*
The moose likes Servlets and the fly likes can servlets have constructor Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "can servlets have constructor" Watch "can servlets have constructor" New topic
Author

can servlets have constructor

maheswari kris
Greenhorn

Joined: Jul 30, 2008
Posts: 1
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

Joined: Feb 19, 2008
Posts: 2902
    
    1

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 !


[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61426
    
  67

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 ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61426
    
  67

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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: can servlets have constructor