How to deploy web applications

There are two ways to deploy web application to actual server.

  • Manually copy the files to target directory
  • Deploying in a war file

It is simple to copy files directly. You can use FTP or Rsync to copy jsp, class, jar file in the web application directory.

Deploying using war file

The second way to deploy a web application is to deploy enclosed .war files. war is an abbreviation of Web Application Archive. It contains the components of web application.

When making war files, you can use jar command JDK provides. Jar command is contained in [jdkDirectory]\bin directory like javac command. You can run jar command without having to enter full path if you add this directory to control path.

In order to create .war file using jar command, use jar command using cvf option as shown belows.

Snip20150520_3

Snip20150520_2

Snip20150520_4

jsp.war next to cvf is name of file to be created, and ‘*’ means file that will be included in .war file. In cvf, “c” means creating new file, “v” means displaying detailed information on the console, and “f” means specifying name of file to be created.

If you run the above command, jsp.war file will bee created in web application directory. You can copy this file to webapps directory of actual server. For example, if we installed tomcat at real\ directory. Tomcat is located in real\tomcat\. Then copy jsp.war file to real\tomcat\webapps directory and run tomcat installed in real\ directory. Then at real\tomcat\webapps directory, directory with same name as war file will be created. In other words, if you run tomcat after copying jsp.war file to webapps directory, “jsp” directory will be created, and you can run “jsp” web application.