3

I am a little confused about the roles of a java application server and its differences from a web server.
I found many sites explaining the same difference between the two but not to my satisfaction.
So please explain me about the two following cases:-

1)App. Server and its difference with web server:

From these two links:
Difference between an application server and a servlet container?
What is the difference between application server and web server?

web server: It handles everything through http protocol by accepting requests from clients and sending
responses to them with the help of its servlet container(e.g Apache Tomcat)
App. Server: An application server supports the whole of JavaEE like JMS,JPA,RPC etc.

Now what I am confused with is that how can I use a lot of JavaEE APIs like JMS,JPA etc. with my Tomcat
by adding their jar files in my web application ?
Does that mean that if I use an appliation server I don't have to add those jar files?(I don't think so)

2)The roles of an appl. server (This is very important to me)

From Wikipedia
http://en.wikipedia.org/wiki/Application_Server

An application server provides services such as security,transaction support etc.
"The term is often used for web servers which support the JavaEE" -- It sounds like if we add the required jar files of JavaEE APIs a web server becomes an appl. server.What about it.

Now my question is how an application server performs the tasks of security control or transaction management by itself ?
E.g. in my web application using Spring framework I am providing security by using spring-security and transaction management by using @Transactional annotation and all those things you know.
So does the appl. server have anything to do with my security or transaction management or it has its own ways ?

Forgive my ignorance.

Community
  • 1
  • 1
mukund
  • 2,866
  • 5
  • 31
  • 41
  • So does the appl. server have anything to do with my security or transaction management ? - YES – Ved Jun 07 '12 at 08:38
  • See also this post for a description of some of the things you don't get from Tomcat that you do get from an app server http://stackoverflow.com/a/9199893/190816 It's not the typical answer that just lists APIs. Gives details on some of the less obvious parts and how they work. – David Blevins Jun 07 '12 at 17:00
  • @DavidBlevins: Thanks thats a nice post. – mukund Jun 08 '12 at 09:21

3 Answers3

3

Using Spring, you're in fact embedding some kind of Java EE container inside your application. But even when using Spring, if you need JTA support (because you need distributed XA transactions), you'll need to use an additional transaction manager. If you need JMS, you'll need to install an additional JMS broker. If you need connection pooling, you'll need to use an additional connection pool. Sometimes it's as simple as adding additional jars to the classpath and properties or XML files. Sometimes it's harder.

A Java EE app server comes with everything bundled. You have less flexibility, but you don't need to install, configure and make everything work by yourself.

Arjan Tijms
  • 37,782
  • 12
  • 108
  • 140
JB Nizet
  • 678,734
  • 91
  • 1,224
  • 1,255
  • 1
    "_A JEE app server comes with everything bundled_" - Does it mean that if you want to deploy your application in an application server, then it is not required to add the jar files of JTA, JMS etc to your classpath ? – mukund Jun 07 '12 at 09:45
  • Yes. The server comes with these API, and an implementation of these APIs. – JB Nizet Jun 07 '12 at 09:45
  • Thank You...I wanted this.But why have you written this _You have less flexibility_. – mukund Jun 07 '12 at 09:51
  • When you use Spring, you may choose Hibernate or EclipseLink as JPA provider, Bitronix or Atomikos as JTA provider, SonicMQ or ActiveMQ as JMS providers, etc. When you choose JBoss or GlassFish, you use what is bundled with GlassFish or JBoss. – JB Nizet Jun 07 '12 at 10:00
  • 1
    Note some things are standardly pluggable to any app server. JPA is pluggable, so EclipseLink, Hibernate or OpenJPA can be used with any platform. JMS is also standardly pluggable via the Java EE Connector API, though it is less commonly done. – David Blevins Jun 07 '12 at 18:06
2

When you use the Java EE framework, that is a specification. So the application server, if it is Java EE compliant, needs to implement this. So once it is implemented the specification, then it will address Security,transaction etc because it is mentioned in the spec. So it is a contract. Whereas, in a web server, it will just pull out your static resource. There is no need for handling other stuff.

In case of the Spring framework, the framework knows how to handle transaction, security etc. So particularly the developer need not look into these aspects which are implemented by the Application Server in the other scenario.

how an application server performs the tasks of security control or transaction management by itself

It is rather the specification that address these issues, not the application server. So, the duty of the app server is to implement these. So, if your application is Java EE compliant, then these areas will be addressed and the implementation would have been done by the app server.

Arjan Tijms
  • 37,782
  • 12
  • 108
  • 140
UVM
  • 9,776
  • 6
  • 41
  • 66
1

May be this is oversimplification,

A web server is basically a HTTP server serving contents over http protocol. So a web server is simply about serving the contents over http protocol. A typical example would be Apache web server. This is simply a file server.

Now the question is where does the web server gets the contents from ? Possible sources are

  1. Static contents (the contents like images/css etc) which are not generated on request but statically served.
  2. Dynamic contents: Simply put, the contents to be served are generated upon the user request.

For the static contents, the web server does not need anything as it simply reads the file and serves it.

For dynamic contents, the web server might need help of additional components which will generate the contents to be served.

Here the Application Server comes into picture.

Now these additional components referred earlier, might interact with database or some other system etc.

In a web environment where your website is exposed to huge number of users (intended/unintended), you need typical services like transaction/security/concurrency etc. so that the user get expected responses and do not see inconsistencies in the behavior of the application.

An application server has inbuilt abilities to manage transaction/security/concurrency/resource management. generally these are referred as Managed services and environment offered by them is called Managed Environment where these basic services are managed by the application server and programmer does not have be bother for them.

Application Server needs web servers or we can say Web servers use Application server's services to generate dynamic contents.

For example, JBoss uses Tomcat as inbuilt web server. Whereas web logic has its own web server. Tomcat again can be called as application server (in principle) as it also offers managed environment for servlets (it manages concurrency and instance pool of servlets/JSPs ).

Coming your your example of Spring: An Application server will come inbuilt with transaction/security etc whether you need it or not. The Spring offers a very nice way handling this. Spring has all these things BUT you use what you need. Not just these, but just a Java Web Sever like Tomcat is sufficient to build a full fledged services that needs an application server.

Santosh
  • 17,667
  • 4
  • 54
  • 79