Relative file path java web application

Relative file path java web application

If you are working on web application and want fetch absolute file which is inside your deployed war file in any server at run time please see below:

  • Example project structure:

Relative file path java web application

  • Now export war file and structure of war file is below:

Relative file path java web application

  • You will have to add below code to get file absolute path from server:

  • Complete file:

  • Now I will run this project inside tomcat server in eclipse and it shows below file path inside server:

Relative file path java web application

 

For more information method please see oracle documentation of Thread class here

download Download Project: SpringMVCRESTFulService

Leave a Reply

Your email address will not be published. Required fields are marked *