Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Read files under WEB-INF directory

 
Yuvi Gupta
Greenhorn
Posts: 20
C++ Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,
I want to get List of all files name(jsp etc) which is under WEB-INF directory. i tried lot but i couldn't do that. Any one can please post the code.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64629
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

What have you tried? Please post your code. At CodeRanch, you don't get the code handed to you, you get lots of help with your code.
 
Yuvi Gupta
Greenhorn
Posts: 20
C++ Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bear Bibeault ,
I have solved my problem by the following statement. Thanks
String [] f=new File(getServletContext().getRealPath("WEB-INF")).list();




 
Ivan Jozsef Balazs
Rancher
Posts: 972
5
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
getResourceAsStream might be a better choice - as getRealPath returns null if the servlet container cannot translate the virtual path to a real path for any reason (such as when the content is being made available from a .war archive).

How to load a resource from WEB-INF directory of a web archive - Stack Overflow
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic