A Web server exclusively handles HTTP/HTTPS requests. It serves content to the web using HTTP/HTTPS protocol.
An Application server serves business logic to application programs through any number of protocols, possibly including HTTP. The application program can use this logic just as it would call a method on an object. In most cases, the server exposes this business logic through a component API, such as the EJB (Enterprise JavaBean) component model found on Java EE (Java Platform, Enterprise Edition) application servers.
The main point is that the web server exposes everything through the http protocol, while the application server is not restricted to it. An application server thus offers much more services than a web server which typically include:
- A (proprietary or not) API
- Load balancing, fail over…
- Object life cycle management
- State management (session)
- Resource management (e.g. connection pools to database)
Most of the application servers have Web Server as integral part of them, that means App Server can do whatever Web Server is capable of. Additionally App Server have components and features to support Application level services such as Connection Pooling, Object Pooling, Transaction Support, Messaging services etc.
An application server can (but doesn’t always) run on a web server to execute program logic, the results of which can then be delivered by the web server. That’s one example of a web server/application server scenario.
As web servers are well suited for static content and app servers for dynamic content, most of the production environments have web server acting as reverse proxy to app server. That means while servicing a page request, static contents such as images/Static html is served by web server that interprets the request. Using some kind of filtering technique (mostly extension of requested resource) web server identifies dynamic content request and transparently forwards to app server.
Example
Web Server : Apache HTTP server, Tomcat Server
Application Server : JBoss, Websphere Application Server(WAS) ,BEA Weblogic