This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes Why Servlet Programming Do Not Need Main Method() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Why Servlet Programming Do Not Need Main Method()" Watch "Why Servlet Programming Do Not Need Main Method()" New topic
Author

Why Servlet Programming Do Not Need Main Method()

Sunil Kumar Sahoo
Greenhorn

Joined: Aug 04, 2012
Posts: 4

Is there any reason why core java programs have an entry point that is main. But Servlets do not have the same. Then From Where the Entry Point Starts in Servlet Programming.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41123
    
  45
The main method is used to run Java code on the desktop (either from the command line or by double-clicking a jar file). Since servlets do not run on the desktop -but on a server inside a servlet container- it doesn't make sense that they would work the same way. Search for "servlet lifecycle" for explanations of how servlets run, and study the javadocs of the javax.servlet.Servlet interface


Ping & DNS - my free Android networking tools app
Sunil Kumar Sahoo
Greenhorn

Joined: Aug 04, 2012
Posts: 4

Thanks Buddy
hari vis
Greenhorn

Joined: Aug 05, 2012
Posts: 3
Hi Sunil,

Main method is the invocation point of any java program. That is where the program execution begins. Having said this, the servlets are extensions of web servers to bring in dynamic contents. They are not the starting point of the web applicaton.There are a lot more things that happen immediately after the server start-up and the servlet instantiation. The servlets are instantiated usually at start-up or on demand. So, there should be something that maintains the servlet instantiation itself; that something is the servlet container. To maintain that servlet container, we need a server. So, when you start a server - java process - you are invoking the main method of the bootstarp library of that server. In case of Tomcat, it's in ../bin/bootstrap.jar library.
Sunil Kumar Sahoo
Greenhorn

Joined: Aug 04, 2012
Posts: 4

Thanks Buddy Hariiiiiiiiiii
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Why Servlet Programming Do Not Need Main Method()
 
Similar Threads
H1B is dying
RichFaces phases manipulation
Not using Maiin()
why static methods can not be overridden
Performance: XML Layout vs api views