Wednesday, November 20, 2013
Tuesday, November 19, 2013
Benefits Of Servlets
The servlet technology is the foundation of web application development using the Java programming language. It is one of the most important Java technologies, and it is the underlying technology for language. It is one of the most important Java technologies, and it is the underlying technology for another popular Java technology for web application development: JavaServer Pages (JSP). Therefore, understanding the servlet technology and its architecture is important if you want to be a servlet developer. Even if you plan to develop your Java web application using JSP pages alone, understanding the servlet technology helps you build a more efficient and effective JSP application.
When it first emerged, this great thing we call the Internet consisted of only static contents written using HTML. At that time, anyone who could author HTML pages was considered an Internet expert. This did not last long, however. Soon dynamic web contents were made possible through the Common
Gateway Interface (CGI) technology. CGI enables the web server to call an
external program and pass HTTP request information to that external program to
process the request. The response from the external program is then passed back
to the web server, which forwards it to the client browser. CGI programs can be
written in any language that can be called by the web server. Over the course of
time, Perl became the most popular language to write CGI programs.
As the Internet became more and more popular, however, the
number of users visiting a popular web site increased exponentially, and it
became apparent that CGI had failed to deliver scalable Internet applications.
The flaw in CGI is that each client request makes the web server spawn a new
process of the requested CGI program. As we all know, process creation is an
expensive operation that consumes a lot of CPU cycles and computer memory.
Gradually, new and better technologies will replace CGI as the
main technology for web application development. The world has witnessed the
following technologies trying to dominate web development:
-
ColdFusion. Allaire's ColdFusion provides HTML-like custom tags that can be used to perform a number of operations, especially querying a database. This technology had its glamorous time in the history of the World Wide Web as the main technology for web application programming. Its glorious time has since gone with the invention of other technologies.
-
Server-side JavaScript (SSJS). SSJS is an extension of the JavaScript language, the scripting language that still rules client-side web programming. SSJS can access Java classes deployed at the server side using the LiveWire technology from Netscape.
-
PHP. PHP is an exciting open-source technology that has matured in recent years. The technology provides easy web application development with its session management and includes some built-in functionality, such as file upload. The number of programmers embracing PHP as their technology of choice has risen sharply in recent years.
-
Servlet. The servlet technology was introduced by Sun Microsystems in 1996. This technology is the main focus of this book and will be explained in more detail in this and coming chapters.
-
JavaServer Pages (JSP). JSP is an extension of the servlet technology. This, too, is the center of attention in this book.
-
Active Server Pages (ASP). Microsoft's ASP employs scripting technologies that work in Windows platforms, even though there have been efforts to port this technology to other operating systems. Windows ASP works with the Internet Information Server web server. This technology will soon be replaced by Active Server Pages.NET.
-
Active Server Pages.NET (ASP.NET). This technology is part of Microsoft's .NET initiative. Interestingly, the .NET Framework employs a runtime called the Common Language Runtime that is very similar to Java Virtual Machine and provides a vast class library available to all .NET languages and from ASP.NET pages. ASP.NET is an exciting technology. It introduced several new technologies including state management that does not depend on cookies or URL rewriting.
In the past, ASP and servlet/JSP have been the main
technologies used in web application development. With the release of ASP.NET,
it is not hard to predict that this technology will become the servlet/JSP's
main competitor. ASP (and ASP.NET) and servlet/JSP each have their own fans, and
it is not easy to predict which one will come out the winner. The most likely
outcome is that neither will be an absolute winner that corners the market;
instead the technologies will probably run head-to-head in the coming years.
Servlet (and JSP) offers the following benefits that are not
necessarily available in other technologies:
-
Performance. The performance of servlets is superior to CGI because there is no process creation for each client request. Instead, each request is handled by the servlet container process. After a servlet is finished processing a request, it stays resident in memory, waiting for another request.
-
Portability. Similar to other Java technologies, servlet applications are portable. You can move them to other operating systems without serious hassles.
-
Rapid development cycle. As a Java technology, servlets have access to the rich Java library, which helps speed up the development process.
-
Robustness. Servlets are managed by the Java Virtual Machine. As such, you don't need to worry about memory leak or garbage collection, which helps you write robust applications.
-
Widespread acceptance. Java is a widely accepted technology. This means that numerous vendors work on Java-based technologies. One of the advantages of this widespread acceptance is that you can easily find and purchase components that suit your needs, which saves precious development time.
Subscribe to:
Posts (Atom)