Important terms used in web application are discussed here.
We’ll be covering the following topics in this tutorial:
Common Gateway Interface (CGI)
The Common Gateway Interface (CGI) is one of the practical techniques developed for creating dynamic content. By using the CGI, web server passes request to an external program and after executing the program the content is sent to the client as an output. In CGI, when the server receives a request, it creates a new process to run the CGI program; so creating a process for each request requires significant server resources and time, which limits the number the of requests that can be processed concurrently. CGI applications are platform dependent. There is no doubt that CGI has played a major role in explosion of internet and its performance and scalability issues make it optimal solution.
Java Servlets
Java Servlet is a generic server extension that means a Java class can be loaded dynamically to expand the functionality of the server. Servlets are used with web servers and run inside the Java Virtual Machine (JVM) on the server so it is safe and portable. Unlike applets they do not need support from Java in the browsers. In contrast to CGI, servlets do not use multiple processes to handle separate requests. Servlets can be handled by separate threads in the same process. Servlets are portable and platform independent.
Web Server
A web server extension is the combination of computer and the program installed on it. The web server interacts with the client through a web browser. It delivers the web pages to the client and to an application by using web browser and the Hypertext Transfer Protocol (HTTP) protocols respectively. We can also define the web browser as the package of large number of programs installed on the computer connected to internet or intranet for downloading the requested files using File Transfer Protocol (FTP), serving email and building and publishing web pages. A computer connected to internet or intranet must have a server program. In Java language, a web server is a server that is used to support the web component like servlet and Java server page (JSP).
A computer connected to the internet for providing services to a small company or a departmental store may contain the HTTP server (to access and store the web pages and file), Simple Mail Transfer Protocol (SMTP) server (to support mail services), FTP server (for file downloading) and Network News Transfer Protocol (NNTP) server (for newsgroup). The computer containing all of these servers is called web server. Internet service providers and large companies may have all these servers and many more on separate machines. In case of Java, a web server can be defined as a server that only supports the web components like servlet and JSP. It does not support the business component like EJB.
Application Server
An application server is a software framework dedicated to the efficient execution of procedures (programs, routines, scripts, etc.) for supporting the construction of applications. Normally, the term refers to Java application servers. When this is the case, the application server behaves like an extended virtual machine for the running applications, handling transparently connections to the database at one side, and connecting to the web client at the other end.
An application server is typically used for complex transaction-based applications. To support high-end needs, an application server has to have built-in redundancy, monitor for high-availability, high-performance distributed application services and support for complex database access.
Servlet Container
A servlet container is nothing but a compiled, executable program. The main function
of the container is to load, initialize and execute servlets. The servlet container is the official Reference Implementation for the Java Servlet and Java server pages technologies. The Java servlets and Java server pages specifications are developed by Sun Microsystems under the Java Community Process (JCP).
A container handles large number of requests as it can hold many active servlets, listeners, etc. It is interesting to note that the container and objects in a container are multithreaded. So each object must be thread safe in a container as the multiple requests are handled by the container due to entrance of more than one thread at a time.
We can categorize the servlet container as:
(a)A simple servlet container is not fully functional; therefore, it can run very simple servlets and do the following:
• Wait for HTTP request.
• Construct ServletRequest object and ServletResponse object.
• If the request is for static method, invoke the process method of StaticResourceProccesor instance, passing ServletRequest object and ServletResponse object.
• If the request is for servlet, load the servlet class and invoke the service method passing ServletRequest object and ServletResponse object. Note that in this servlet container, the servlet class is loaded every time the servlet is requested.
(b)A fully functional servlet container additionally does the following for each HTTP request:
• When the servlet is called for the first time, load the servlet class and its init method (once only).
• For each request, construct an instance of javax. servlet. ServletRequest and an instance of javax. servlet. ServletResponse objects.
• Invoke servlet’s service method, passing ServletRequest object and ServletResponse object.
• When the servlet class is shut down, call the servlet’s destroy method and unload the servlet class.