Servlets are preferred by developers who are working on developing Server side programs and applications as it has platform-independent methods and do not have the limitations of CGI programs. This makes the programs and application fast and efficient.
Servlets are mostly used to develop interactive Web-based applications that can run on any servlet enabled web server. Servlets use of Java language and a standard framework makes it the first choice for developers to create sophisticated server side extensions.
Developers use Servlet to add dynamic content to a web server. Servlets generally embed HTML inside Java code. Servlet receives a request from user and generates a response and displays it back to the user.
Servlets can access Java APIs and JDBC API and a HTTP-specific library. All servlets must implement the Servlet interface. doGet() method and doPost() methods are used to handle HTTP-specific services.
Servlets are also used to store and process data.
Lifecycle of Servlets:
Every client request is received on a different thread.
Servlets container generates a default page reading "A Servlet Exception Has Occurred" when an error occurs while servlet executes.
If you enjoyed this post then why not add us on Google+? Add us to your Circles
Liked it! Share this Tutorial
Discuss: What is Servlet in Java?
Post your Comment