While in interview I have some what explained the difference by intuition but was not very clear about the answer
on theoretical grounds. My answer was
Web Server makes subset of Application Server as it server only web application while application server can serve web and other type of applications
Later I searched web on this topic and found similar explanations.
Q. What is the difference between an application server and a Web server?
A. Taking a big step back, a Web server serves pages for viewing in a Web browser, while an application server provides methods that client applications can call. A little more precisely, you can say that:
The Web server
A Web server exclusively handles HTTP requests, whereas an application server serves business logic to application programs through any number of protocols. A Web server handles the HTTP protocol. Understand that a Web server's delegation model is fairly simple. When a request comes into the Web server, the Web server simply passes the request to the program best able to handle it. The Web server doesn't provide any functionality beyond simply providing an environment in which the server-side program can execute and pass back the generated responses. The server-side program usually provides for itself such functions as transaction processing, database connectivity, and messaging.
The application server
As for the application server, according to our definition, an application server exposes business logic to client applications through various protocols, possibly including HTTP. In most cases, the server exposes this business logic through a component API, such as the EJB (Enterprise JavaBean) component model found on J2EE (Java 2 Platform, Enterprise Edition) application servers. Moreover, the application server manages its own resources. Such gate-keeping duties include security, transaction processing, resource pooling, and messaging.
One more interesting thing which has reduced the difference lines between web and application server
Recently, XML Web services have blurred the line between application servers and Web servers. By passing an XML payload to a Web server, the Web server can now process the data and respond much as application servers have in the past.Hope you have well understood the concept. So keep watching for more interview teasers
Some of the contents of this post are taken from Java World