This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Read files under WEB-INF directory  RSS feed

 
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
Posts: 66141
141
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: 999
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!