The main functions of Servlet container are: 1. Lifecycle management : Managing the lifecycle events of a servlet lik class loading, instantiation, initialization, service, and making servlet instances eligible for garbage collection. 2. Communication support : Handling the communication between servlet and Web server. 3. Multithreading support : Automatically creating a new thread for every servlet request and finishing it when the Servlet service() method is over. 4. Declarative security : Managing the security inside the XML deployment descriptor file. 5. JSP support : Converting JSPs to servlets and maintaining them.
It is a method in which the output of one servlet is piped into the next servlet. - It is the last servlet in the chain that provides the output to the Web browser.
While using a ServletRequest a relative URL can be provided, which can not be done while using ServletContext.
Calling a doPost() method inside doGet() and doGet()method inside doPost() wouleate a deadlock for a servlet.
The important used of HTTP Servlets are: - Storage and processing of data submitted by an HTML form. - Providing dynamic content to the client for example outputting the result of a query. - Improving the system performance by handling multiple requests at a time. - Managing state information on top of the stateless HTTP.
The default implementations of the main service methods can not do anything and need to be overridden. This calls of the HttpServlet class to be declared as abstract. - With its use the developers do not need to implement all the service methods.
When you use GET, the entire form submission gets encapsulated in one URL. The query length is limited to 260 characters, not secure, faster, quick and easy.When you use POST your name/value pairs inside the body of the HTTP request, which makes a cleaner URL. It imposes no size limitations on the form output. It is used to send a large amount of data to the server to be processed. It is comparatively more versatile and secure.
GET is preferred over POST in most of the situations except for the following: - When the data is sensitive. - When the data is greater than 1024 characters.
Building a DOCTYPE line informs the HTML validators about the version of HTML you are using. This tells them the specification against which your document should be checked. - These validators work as valuable debuggers which help you catch the HTML syntax errors.
Although the init method of the servlet initializes it, a constructor instantiates it.A developer might never explicitly call the servlets constructor but a container uses it to create an instance of the servlet.
The servlets are not initialized by the container from the start. It happens when the servlet is requested for the first time. This is called lazy loading.
There are two ways to destroy a session: 1. Programatically : By using session.invalidate() method. It makes the container abandon the session on which the method is called. 2. When the server shuts down.
- GenericServlet is an abstract class which implements the Servlet interface and the ServletConfig interface. - Other than the methods included in above two interfaces, it also provides simple versions of the lifecycle methods init and destroy, and implements the log method declared in the ServletContext interface. - Since this class is not specific to any protocol, it is known as generic servlet.
Simple and dept learning technology is very important part in software development. Same story has been implemented at this site, so learn and implement the inovative things, Thanks
Ravi Kumar Verma