Take the 2-minute tour ×

I do not understand exactly what an application server like Tomcat, Weblogic, Websphere, GlassFish etc. does.

I know that a war can be placed inside an application server and then the application server needs to be started in order to have the servlets running. I also know (not sure if true) that when developing enterprise applications, the libraries included for Java EE provide only the interfaces; the code being held in the application server an called at run-time. From Wikipedia I also learned that "An application server is a server which provides software applications with services such as security, data services, transaction support, load balancing, and management of large distributed systems".

But I do not understand what exactly an application server does and how it does it; if you know some good tutorial (or book) about this, or are willing to give a more detailed explanation about this, please answer.

share|improve this question
add comment

4 Answers

up vote 7 down vote accepted

Here are some of the StackOverflow answers I've written that give some insight as to how application servers work. Incomplete and assumes a certain level of familiarity with each subject, but might be helpful depending on where you are at with your learning.

share|improve this answer
add comment

An application server provides the pieces you need to run Java EE applications. So what do you need to run Java EE applications?

JavaMail example: JavaMail (sending and receiving email) is a part of Java EE. To use JavaMail you need to have access to the JavaMail classes and interfaces. This means you need the JavaMail related JARs (zips of classses) to be in your CLASSPATH. You can either: a) download the JARs yourself and add them as libraries to your project or b) run your application inside of an application server which will provide all the JavaMail classes.

Servlet example: You want to dynamically produce HTML content. A common example is banking, a user enters a URL and some Java code runs that gets your account balances from a database and makes a custom web page just for you. In this case some one need to handle the TCP/IP connection from the web browser, parse the HTTP request, figure out the URL the browser requested and call the Java class that handles making the account balances HTML table. An application server includes a web server (also called a web container) that does most of the heavy lifting. You just have to write a "plugin" to the web server to add in your application specific behavior. The plugin is called a Servlet.

A large part of learning Java EE is not just learning the API but understand the behavior of the application server. There is a lot of lifecycle stuff that goes on. Given a certain sequence of events the application server will attempt to find and call methods in the classes you provide.

The reason they exist...You can implement that dynamic banking web page with just Java SE. You'd probably start of with java.net.ServerSocket and work your way from there. You could easily spend a year trying to make a good solid application that read the HTTP requests and could send HTTP responses. It'd seem easy at first but the more testing you do the more security and scalability bugs you'd find. In the long run what you really want to do as a developer is solve business problems and not write infrastructure code. Application servers are prewritten infrastructure code, you just need to figure out how to plugin your business logic into them.

So application servers provide a large number of additional libraries beyond Java SE but they also provide services like the web server.

Additionally, not everything about a Java EE application server is part of the Java EE standards. How you add your applications into the server, is the administration done via command line or web page, is clustering and failover supported are all things that vary from one application server to another. Java EE application servers give you some amount of code and API portability but the administration side is specific to that particular application server.

share|improve this answer
You haven't read the details about the question. –  m3th0dman Jun 13 '12 at 6:47
The question "What does an application server do?", The is answer "provide libraries and services". If you are interested in a specific aspect of an application application server behavior please ask "How does an application server provide feature XXX". –  Chase Jun 13 '12 at 15:07
add comment

Just some more info here:

An Application Server wraps your application and takes care of instantiating it and providing access to it.

For example, in Tomcat's case, it will bring up a web server, associate your servlets to a URL, and then invoke your app when the URL is accessed.

In other cases, as in Java EE applications, you can have multiple servers that offer a service together. Depending on network locality, current load and others, they can choose what server to actually instantiate your application in, making it much more scalable.

So, think of app servers as smart containers. They take care of the common tasks that all apps do, and let you focus on your actual application logic. From the outside, they'll call your application when needed. From the inside, you'll be able to get services from the container.

Hope this helps!

share|improve this answer
That's actualy the framework's job (take care of the common tasks that all apps do, and let you focus on your actual application logic) and as I said I know that these servers have the implementation of the APIs for frameworks (Java EE or Spring). Is this the main purpose of an application server? Also how does it work? –  m3th0dman Jun 8 '12 at 14:34
I'd say so. (a) implement a framework and (b) take care of the execution environment of your software –  Miquel Jun 8 '12 at 15:16
add comment

Maybe Oracle's official Java EE tutorial will help you: http://docs.oracle.com/javaee/6/tutorial/doc/

share|improve this answer
In case it speaks of application servers it must speak of GlassFish not the concept as a whole. –  m3th0dman Jun 8 '12 at 14:35
add comment

Your Answer


