File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Read files under WEB-INF directory Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Read files under WEB-INF directory" Watch "Read files under WEB-INF directory" New topic
Author

Read files under WEB-INF directory

Yuvi Gupta
Greenhorn

Joined: Apr 25, 2013
Posts: 13

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

Joined: Jan 10, 2002
Posts: 61106
    
  66

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Yuvi Gupta
Greenhorn

Joined: Apr 25, 2013
Posts: 13

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

Joined: May 22, 2012
Posts: 867
    
    5
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Read files under WEB-INF directory