Wednesday, February 19, 2014

How the servlets works

While start up the servlet container pre-load servlets in the memory if the servlet is defined in the web.xml.If not there in the web.xml the servlet is getting loaded on first time access.First time the servlet loads it will call the init() method. Init method is getting used to initialize the objects like db connection file connection etc.Each time the user make a request to the servlet the service method is getting called which is overridden in doGet() and doPost() methods.The response from these method back to container and to the browser.Web application is a collection of jsp,sevlets,images ,css etc , packaged to a .war file.Servlet container normally have one instance of servlet.If the servlet implements single threaded model multiple instance of servlets are possible.In order to convert your servlet into distributable the servlet should implement single threaded model and in the deployment descriptor make the servlet as distributable.

No comments: