J2EE can be broken up into different technologies. You can split it into technologies EJBs and Servlet/JSPs.
So each requires a different "server/container" EJBs reside in an App Server containter, and Servlet/JSPs reside in a web server. an App Server container cannot serve up Servlets/JSP or HTML, but a web server can.
Some "App Servers" like JBoss and Oracle App Server come bundled with a Web Server.
Apart from Mark reply I want to add some more points
AppServer provides a lot of functioanlity which is not available with web server. If you want to use that functioanlity with Web server than you have to code yourself. AppServer is making the coders life simple so they can put their effort on logic.
A web server can only understand the http request and serve that request with static pages(html,gig,jpeg etc). Whereas the application server may have web server embeded in it and apart from just understanding the http request it can also run the coressponding business logic(ejb) and generate the pages dynamically(jsp) with the help of controller component(servlet). So when a request reaches a web server, it will only know which static page to show. Where as an application server can dynamically generate static html using its (servlet,jsp,ejb) containers.
The lines have become more blurred recently so I'll start with first principles:
As Mark stated, application servers are 'Containers that manage multiple applications', fully blown J2EE app servers manage resources, object lifecycle s, clustering and a whole stack of other responsibilities. Originally application servers were interacted with via a 'servlet container' sub part typically for HTTP communication, but this is no longer necessary. You can talk directly to EJBs or expose the functionality in a number of ways.
Web servers were originally designed to serve static content and still have a number of features which mean they tend to do this better than servlet containers, but this is a rough guide rather than a rule. You can get 'add-ons' for web servers to get them to return dynamic content. These are typically based on the old CGI design (originally C and PERL) but now there are a number of languages you can write dynamic content with.
The lines blur since some application servers include web servers embedded, and web servers have ways to embed application-server behaviour. For example, Websphere includes IBM's own tailored Apache server. This Apache server is completely configured and controlled by the app server. I'd give some examples (maybe BroadVision, Vignette or ColdFusion?) on the opposite, but I'm not sure on my facts so I don't want to give mis-information.
Joined: Sep 15, 2005
what are the components of a webserver and an application server.How is a request processed and the response generated in both the web and the appln server?