Tuesday, July 27, 2021

5 Difference between Application Server and Web Server in Java?

Application server and web server in Java both are used to host Java web applications. Though both the application server and web server are generic terms, the difference between the application server and the webserver is a famous J2EE interview question. From on Java J2EE perspective, the main difference between the web server and application server is the support of EJB. In order to run EJB or host enterprise Java application (.ear) files, 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.

This Java interview question is in continuation of my previous post on interviews like Top 10 Spring interview questions and  Top 10 Struts interview questions.  Here we will see some differences between the 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 transactions and EJB. While Web Server only supports Servlets and JSP.

2. Application Servers can contain web servers in them. most of App server e.g. JBoss or WAS has Servlet and JSP container.

3. Though it's not limited to Application Server 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 the logical difference between the web server and application server. the webserver is supposed to provide http protocol level service while the application server provides support to web service and exposes business-level service e.g. EJB.

5. Application servers are heavier than web servers in terms of resource utilization.

5 Difference between Application Server and Web Server in Java?



Personally, I don't like to ask questions like the Difference between Application Server and Web Server. But since it's been asked in many companies, you got to be familiar with some differences. Sometimes different interviewers expect a different answer but I guess from 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:

8 comments :

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.

Greetings.

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.

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.

Java basic concept said...

can any one explain difference between web application and enterprise application

Anonymous said...

@Sunil, Web application refers to Java application which just uses the web technologies like JSP, Servlet, HTML, CSS and JavaScript and enterprise application is the one which uses EJB. in other words, you need web server or servlet container to run the web application but an application server to run enterprise Java application.

Anonymous said...

web server provides environment with basic HTTP protocol handling.
Web server doesn't provide connection pooling, custom security and can't be integrated with any other servers as is.
Web server communicates via HTTP protocol only.


Application server uses web server for environment and provides the business logic implementation for dynamic handling of requests.
Application server provides connection pooling, custom security implementation and can be integrated with other servers(OpenAM,DB).
Application server can communicate via multiple protocols like HTTP,SMTP,FTP etc..

Anonymous said...

What is the difference between the Enterprise application Nd Distributed application

expnik said...

can there be two different servers ie one web server and one application server for single web application. If yes then where do we deploy WAR file . On web server or application server.what is difference between deploying on application server and web server?

Post a Comment