Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Can we write a constructor for a Servlet class ? if yes how ?
if no why not ?

Answer Posted / tharun raj

yes, we can provide a constructor in servlet calss..
Webcontainer uses the similar code shown below for creating
servlet object for our servlet class

Class c=Class.forName("OurServlet");
Object o=c.newInstance();

this newInstance() method uses zero argument constructor
while creating object..

Is This Answer Correct ?    10 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Who is responsible to create the object of servlet?

1251


How is an application exception handling is done using a servlet?

1057


How can the referrer and the target urls be used in servlet?

1057


What's the difference between servlets and applets?

1096


Explain the difference between servlet and cgi?

1211


What is the advantage of Servlets when compared with other server side technologies?

2393


What are the features added in Servlet 2.5?

1317


What are the difference between session and cookies in servlet? Explain

1092


Explain the role of dispatcherservlet and contextloaderlistener.

1258


Tell us something about servletcontext interface.

1142


Write a command to get actual path of a servlet to the server?

1075


What do you mean by cgi?

1012


What is cgi?

1066


What are life cycle methods of a servlet?

1111


Is servlet a framework?

1092