File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Tomcat and the fly likes Why to extract war file? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Why to extract war file?" Watch "Why to extract war file?" New topic

Why to extract war file?

smitha rajgopal

Joined: Sep 22, 2005
Posts: 14
I was asked this question in an interview.Why should we create a war and extract the war to webapps.Why not copy the folder directly and run.Please le t me know the answer

Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
For easier distribution - it's just a single file to copy. We have a web app that has more than 34000 files; copying those over the network would take a long time.

It's also more orderly to initialize. The servlet engine knwos what to do with a war file, while if you copy individual files, it might try to start initializing the web app as soon as it sees the web.xml file, which may be too soon (because some files are still missing).
Imran Jack
Ranch Hand

Joined: May 05, 2008
Posts: 31
how can we extract war file ??? I had tried winRAR, on right-click it give options to further compress it and does not have options like extract etc.
Imran Jack
Ranch Hand

Joined: May 05, 2008
Posts: 31
>jar -xvf struts2-mailreader.1.1.war
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

You don't need to extract them.
Tomcat will do it automatically.

Simply drop your war file in the tomcat/webapps directory and Tomcat will take care of the rest.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
I agree. Here's the link:
subject: Why to extract war file?
It's not a secret anymore!