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:

/index.html
/login.jsp
/WEB-INF
/WEB-INF/web.xml
/WEB-INF/lib
/WEB-INF/lib/myapp.jar

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
0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact