• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

path of application

 
raj baig
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,

can you tell me how to get my complete path of web application.

like: c:\prog files\tomcat\webapp\myapp

how can i get this path in my servlet

thank you all.
 
Eddy Lee Sin Ti
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In your JSP, you can use application.getRealPath("/"). In your servlet, use the ServletContext.getRealPath("/").

One thing to note is that not all containers deploy your application by exploding them into certain directory. Some is using the WAR/EAR file as a whole.
 
raj baig
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in case of war file can you tell me how to achieve the path
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Depends what you want to do. If you want to write/edit files, it is not so easy. If you are looking to read from a file, you can (usually) use the ClassLoader to find an InputStream from files in the WAR/EAR
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic