• Post Reply Bookmark Topic Watch Topic
  • New Topic

Loading a file from classpath

 
M Mehta
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am working on a web application in RAD with websphare server. I have a propoerties file which is in /WEB-INF/classes folder. I am not able to load the file by accessing only through its name. I have to get the absolute path to by using



to get the file. What settings I need to do so I don't have to append the absolute path before file name. I have also tried classpath:filename, but it doesn't work.

Thanks,
Me
 
Paul Clapham
Sheriff
Posts: 21892
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The usual way to access a file in the classpath is like this:

 
Rob Spoor
Sheriff
Posts: 20820
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you ever need to use absolute file names within a Servlet container, use ServletContext.getRealPath.
 
M Mehta
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Paul, Its working for me now.

However, just wanted to know if there is any way i can make settings in web.xml or somewhere so my propoerties files are loades by name only or by itself?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!