File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes Regarding WAR & EAR Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Regarding WAR & EAR" Watch "Regarding WAR & EAR" New topic
Author

Regarding WAR & EAR

Sriram Sharma
Ranch Hand

Joined: Apr 12, 2006
Posts: 97
Hi All,

I remember that in many J2EE applications, we have a web server, app server and DB call finally.
I have a set of questions here...
1. Why do we need 2 servers on the first hand?
2. What is the difference between a web server and an app server?
3. What is the exact flow of request and response in such a case?
4. Where is the WAR deployed and where is the EAR deployed (in web server or appserver)?

It will be of great help if somebody can give be a step by step explanation of these 4 questions.

Thanks.

Regards,
Ram
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
Once you get the answers to these questions, you can then be a Java Architect on your resume.

Good luck!
Niv Tyagi
Greenhorn

Joined: Oct 14, 2009
Posts: 21

I am going to give this a try.

1. Why do we need 2 servers on the first hand?
Appservers(JBoss/Weblogic) are your containers where you deploy your war or ear file. Whether you use war or ear its up to you.
Webservers (apache/IIS/iplanet) are good to hold your static content (images,htm, docs, etc...). Webservers are good at furnishing static content and would recommend to always have one.


2. What is the difference between a web server and an app server?
see above response.

3. What is the exact flow of request and response in such a case?
The request always hits the webserver first , [Now again this depends on how the environment is setup. Sometimes there are loadbalancers sitting between the user and the webservers, But for now you can assume the request always hits the webserver first.]
Webservers are smart enough to understand what request they can furnish and what needs to directed to the appserver. I have worked with apache webserver and in apache you can set this using a properties file.


4. Where is the WAR deployed and where is the EAR deployed (in web server or appserver)?
Both war & ear reside on the appserver.

Hope this help, if you have further questions/concerns/comments just shoot...
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61216
    
  66

"darth vader", please check your private messages for an important administrative matter.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Sriram Sharma
Ranch Hand

Joined: Apr 12, 2006
Posts: 97
The explanations were pretty clear.
Thanks for that Mr.Tyagi...

Now, I have few more questions...

1. Cant we deploy war or ear in web servers? I believe we can!
2. When I googled for this, came across with some interesting information. It goes here in the next line.
"The Web server can directly reference WAR files, and there is no need to extract them back into directories and files in order to deploy them" - How is it that a webserver direcly accessess a war file? What is it that is happening here?
3. Can't we just do with app server alone? Why is a web server needed at all? If webserver can hold static contents, cant the app servers do that as well

Somebody.. please help me out in this.

Regards,
Sriram
Niv Tyagi
Greenhorn

Joined: Oct 14, 2009
Posts: 21
Sriram Sharma wrote:The explanations were pretty clear.
Thanks for that Mr.Tyagi...

Now, I have few more questions...

1. Cant we deploy war or ear in web servers? I believe we can!
<darthvader> No this cannot be done. web servers are inherently used to furnish only static content in java/j2ee world</darthvader>

2. When I googled for this, came across with some interesting information. It goes here in the next line.
"The Web server can directly reference WAR files, and there is no need to extract them back into directories and files in order to deploy them" - How is it that a webserver direcly accessess a war file? What is it that is happening here?
<darthvader> Not sure what you mean by "directly reference". But i will add this, web servers can be made smart enough to understand what request to furnish and what to send to app server to process. In apache this is accomplished by uriworkermap.properties & modJK. </darthvader>

3. Can't we just do with app server alone? Why is a web server needed at all? If webserver can hold static contents, cant the app servers do that as well
<darthvader> You can, nothing stops you from using the appserver alone, but in case of big enterprise application you can offload the appserver by using a web server as a front end. </darthvader>

Somebody.. please help me out in this.

Regards,
Sriram
Sriram Sharma
Ranch Hand

Joined: Apr 12, 2006
Posts: 97
Awesome Thanks a lot...
They made my thoughts pretty clear.
With respect to my 2nd question, here below I have pasted the link

http://msdn.microsoft.com/en-us/library/aa478983.aspx

You can find the following statement in this link...
"Deployment of JSP Web applications is quite different from deployment of ASP.NET applications. JSP applications are packaged into Web Archive (WAR) files that must then be copied to the Web server. The Web server can directly reference WAR files, and there is no need to extract them back into directories and files in order to deploy them."

If you are able to understand this, please enlighten me as well.
Based on the above statement only I got the feel that war/ear can be deployed in web servers.

Regards,
Sriram
Niv Tyagi
Greenhorn

Joined: Oct 14, 2009
Posts: 21

First rule do not refer to any microsoft links when developing.
These suckers have no idea about development.
The link refers to web servers and then talks about tomcat it does not get better than this.(fun intended).
You can ignore this link.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Regarding WAR & EAR