This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets 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: 60732
    
  65

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: 866
    
    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
 
 
subject: Read files under WEB-INF directory
 
Similar Threads
Request Resource not available.
taglib uri error
struts taglib issue
root context need help
Unable to load tag handler class!!!