0

i have a .html file in war file and war file is in

D:/foldername/jboss/server/default/deploy/sampleproject.war

How to retrieve this path. Please help me on this.

dafodil
  • 531
  • 15
  • 30
  • In future Servlet API related questions, please do not use [java] tag, use [servlets] instead. See also my comment on your other question on this subject. – BalusC Jun 07 '16 at 11:17
  • @BalusC Here i need to get path war file that is present in server.But what you have redirected to question that wont fetch path ,anything like that. – dafodil Jun 07 '16 at 11:27
  • @BalusC Can you show me how to get path of war file in server – dafodil Jun 07 '16 at 11:53
  • It shows how to get a resource (as input stream) from webcontent. You should not be interested in the absolute path at all as that's not portable (this is also explained and linked in the duplicate). – BalusC Jun 07 '16 at 12:45
  • @BalusC i need to get pathname of a file in web Container.I am trying with this code but it shows error for getServletContext() and tells to create method for it.getServletContext().getRealPath("/filepathInContext").How could i create method for it. – dafodil Jun 07 '16 at 13:06
  • Put/call the code in a normal servlet class. And, please DO NOT use `getRealPath()`. This is recipe for disaster. Again, carefully read the duplicate how to properly access resources in a WAR. – BalusC Jun 07 '16 at 13:08
  • @BalusC I need to get context path without depending on servlets,as i need to get path of context in method of bussiness layes,is there any way i could get.even if it is through xml file is okay.Please help me on this. – dafodil Jun 09 '16 at 07:25

0 Answers0