Java servlet is a key component of server-side Java development. A servlet is a small, pluggable extension to a server that enhances the server's functionality.
A servlet is a server-side Java class that can be loaded dynamically to expand the functionality of a server.
while servlet can be used to extend web servers, providing a powerful, efficient replacement for the CGI script. To understand the power of Servlets, we need to step back and look at some of the other approaches that can be used to create web applications.
- Servlet is commonly used with a web server.
- It is used to create a dynamic web page.
- It is used to developing a dynamic web application.
Servlet Architecture |
Common Gateway Interface:
The Common Gateway Interface, normally referred to as CGI, was one of the first practical technique for creating dynamic content. With CGI, a web server passes a certain request to an external program. The output of this program is then sent to the client in place of a static file.
Advantages of CGI:
1) CGI script works with any web browser as well as with most web server running on Windows and Unix.
2) It is a language independent. It can be written in a variety of languages
(c,c++,Perl etc), so the developers don't have to learn a new language.
(c,c++,Perl etc), so the developers don't have to learn a new language.
Disadvantages of CGI:
1) When a server receives a request that accesses a CGI program, It must create a new process to run the CGI program and then pass to it. Creating a process for each such request requires time and significant server resources, which limits the numbers of request a server can handle concurrently.
CGI |
Advantages of Servlet:
1) Servlets are written in Java, they are highly portable across operating system and across server implementation.
2) Servlets are also well suited for enabling client/server communications.
3) Servlets are platform-independent, the web application developed with servlet can be run on any web container such as Tomcat, Glassfish, JBoss server, etc.
4) Servlets provide better performance in terms of processing time, memory utilization because Servlets uses the benefits of multithreading and for each request, a new thread is created.
Servlet |
6) Servlets are managed by JVM so no need to worry about memory leakage, garbage collection, etc.
7) Servlets are secure because it uses java language
8) Servlets are protocol-independent they use any protocol like(FTP, HTTPS, NNTP, etc)
What is Servlet in Java?
Reviewed by Prashant Srivastava
on
September 22, 2018
Rating:
No comments: