• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why Servlet Programming Do Not Need Main Method()

 
Sunil Kumar Sahoo
Greenhorn
Posts: 4
Chrome Oracle Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42968
73
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Sunil Kumar Sahoo
Greenhorn
Posts: 4
Chrome Oracle Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Buddy
 
hari vis
Greenhorn
Posts: 3
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
Chrome Oracle Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Buddy Hariiiiiiiiiii
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic