How can I deploy my JSP files within a WAR file?

Ryan Breidenbach

A WAR file is basically a JAR containing a web application. It is a convenient way to package all resources necessary for a web application. For more information on this, see What is a web application?

As for deploying JSPs in a WAR file, you simply place them in the same hierarchy in your WAR as you want them accessed in your application. For example, say your directory structure for your WAR file looks like this:


Assuming that the above files are located within a directory called "staging", you can create the WAR file as:

jar cvf myapp.war -C staging .

Where you deploy the WAR file will depend on the server you are using. Then, index.jsp would be accessed relative to the root of you web application. So, if you web app's root was http://someserver/myapp, then the URL for your JSP would be http://someserver/myapp/login.jsp