This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I'm a novice and I don't have big experience about the .war deploy, and I would like to know whether to deploy a web project by .war file is the better solution or no.
If my project is small, I'll not have problems to deploy everything again, but if my project has a medium size, I'll need to re-deploy everything (e.g. a lot of pictures) only why I need to fix a line of code.
Maybe I can re-deploy only the single file, but in this case the .war is useful only the first time I deploy my web application.
And if I have some text files created from my application, when I deploy the .war file are they deleted?
Since JSP, Servlet and JSF components are used to concentrate solely on presentation logic, it makes sense to put them into a separate module (as WAR file). The web related artifacts (Facelets, backing beans, servlet class files, JSP files, supporting class files, GIF and HTML files, and a web application deployment descriptor) go into a Web Archive (WAR) file which represents the Web module.
By automated build task like ANT, we can easily deploy the application by single command. Java EE 6 improved lot to simplify EJB deployment as well. You no need to create seperate JAR file for EJBs, just copy .class into WAR file.
[WAR] The deployment process expands the EAR/WAR file into a temporary directory and (conceptually), the compressed EAR/WAR file is considered to be the application.
[Expanded directory] You can expand the EAR/WAR file manually, and then deploy the expanded directory structure, which becomes your working directory.
Why WAR/EAR deployment?
Application isolation Separate class loaders
Problems encountered by one application have no effect on other applications
Choosing the option (WAR or Expanded directory) is depends on your project complexity. But it is always better to use WAR deployment to to test your production issues.