bsel
bsel

Reputation: 197

How to get the path of web application's war file?

I need to get the full file path of war file using just the war file name as input. I mean, the return value should be like C:/PFiles/project/tomcat/sender/sender.war

I have tried to get the path using the following, but it doesn't give me the correct path.

File file = new File("sender.war");
String path = file.getAbsolutePath();

How to find the correct path?

Upvotes: 2

Views: 2304

Answers (1)

RP-
RP-

Reputation: 5837

Try using the system property of tomcat. String tomcatHome = System.getProperty( "catalina.base" );

This will give you the home directory from there you can add tomcatHome+"webapps/yourwar".

Upvotes: 3

Related Questions