Friday, May 18, 2012

5 Difference between Application Server and Web Server in Java

Application server and web server in Java both are used to host Java web application. Though both application server and web server are generic terms, difference between application server and web server is a famous J2EE interview question. On  Java J2EE perspective main difference between web server and application server is support of EJB. In order to run EJB or host enterprise Java application (.ear) file you need an application server like JBoss, WebLogic, WebSphere or Glassfish, while you can still run your servlet and JSP or java web application (.war) file inside any web server like Tomcat or Jetty.

What are difference between application server and web serverThis Java interview question are in continuation of my previous post on interviews like Top 10 Spring interview questions and  Top 10 Struts interview question.  Here we will see some difference between application server and web server in point format which will help you to answer this question in any java interview.

Application Server vs Web Server

1. Application Server supports distributed transaction and EJB. While Web Server only supports Servlets and JSP.
2. Application Server can contain web server in them. most of App server e.g. JBoss or WAS has Servlet and JSP container.

3. Though its not limited to Application Server but they used to provide services like Connection pooling, Transaction management, messaging, clustering, load balancing and persistence. Now Apache tomcat also provides connection pooling.

4. In terms of logical difference between web server and application server. web server is supposed to provide http protocol level service while application server provides support to web service and expose business level service e.g. EJB.

5. Application server are more heavy than web server in terms of resource utilization.

Personally I don't like to ask questions like Difference between Application Server and Web Server. But since its been asked in many companies, you got to be familiar with some differences. Some times different interviewer expect different answer but I guess on Java's perspective until you are sure when do you need an application server and when you need a web server, you are good to go.

Other Java Interview questions post you may like:


Javier said...

Apologize, but I disagree with one term

I call Web Server to the application that serves HTML pages, with its images and so on. What I call static content.

Tomcat and Jetty are known as Servlet engines.


Jirka Pinkas said...

I agree with Javier. Web server is an application for serving static content. For example Apache HTTPD is a web server.

Tomcat and Jetty are called web containers or servlet containers.

Olya Olegovna said...

Good information here. I will post these information to my facebook page. It is really very informative for others. FSD solutions

Sandeep said...

Thanks for elaborating it.
I think that the main point is that the web server exposes everything through the http protocol, while the application server is not restricted to it.

Post a Comment