This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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

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
It's not a secret anymore!