Meaningless Drivel is fun!
The moose likes Servlets and the fly likes not main() in servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "not main() in servlet" Watch "not main() in servlet" New topic

not main() in servlet

bakiyalakshmi dhanraj

Joined: Nov 02, 2007
Posts: 24
Why main() is not written in servlets programs
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

It is all about 'entry points'

When you call a class from the command line, the entry point into your class is the main method.

When you call a Servlet or JSP, the entry point is the service() method, but by default it then calls the doGet or doPost methods for us, so we use these entry points instead.

Applets have a different entry point, they don't have a main() method either.

EJBs are different again.
I agree. Here's the link:
subject: not main() in servlet
jQuery in Action, 3rd edition