A Review of Internet Technology Part 3 – Web Server

By | December 13, 2011

 The foundation of web Tier is the web server, and its task is to receive HTTP requests and directs it to a server based on a URL. When the web server receives the request from the browser, it decides how to respond to it, if the request is for a file then the web server returns that file and this is the way most static HTML files are handled.  However if the requests may be to execute a program that will generate the response, and in this case web server executes the program and then generate the response which is either an HTML, XML, CSS, JavaScript, an image or anything else that can be transferred over HTTP. Or if the requests is to get some logic and display, then the web server sends the request to servlet container to run the servlet and get the appropriate method to run the functionality and send the response back. The life cycle of the servlet (init(),service() {doGet(), doPost()}, destroy()) get managed by a servlet container.

 

 One of the most popular web servers is Apache web server, because of high performance, and support of advanced features. It also supports PHP script to process dynamic contents. It is recommended to install and configure Apache in enterprise environments in production in front of server Container or application server.

 You may ask why? Because when it comes to hosting servlet or handling servlet life cycle, servlet containers like Tomcat or Jetty can handle the request properly, or for hosting J2EE applications JBoss, Weblogic, Websphere and similar enterprise applications servers are perfect but when it comes to serving static content, providing load balancing, URL rewriting, SSL handshakes and etc. web servers like Apache are best choice.

In web Tier we have web servers and servlet containers. What is the difference of the two? As each have its own purpose and a servlet container can handle and process HTTP directly but a web server cannot process a servlet as it doesn’t have servlet engine. So for development usage you often don’t need the web server however for production purposes, having a web server can be beneficial for the above reasons. Another reason to front end a servlet container or application server with a web server is for security reason. On Unix or Linux systems to run a servlet containers or application servers on port 80, the container must be running as root, and this is not a acceptable security risk as a program running with root privileges could possibly be taken over, usually these programs start as root but then immediately lower their access level once the port is open.

 Some of the most famous web servers are Apache HTTP server that I mentioned before, then Internet Information Services (IIS) from Microsoft, Sun Java Web Server from Sun formerly known as iPlanet and some of the common features and functions among all are:

Caching, Content Integration, Log files, Mapping URLs to system locations, Access control to filesystem to preserve the security, SSI or Server Side Includes, Virtual Hosting in order to have more than one web site on a Single server which it can be IP-Based, or
Name-Based.