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

how to read a folder outside the context  RSS feed

 
jo sim
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My current application setup is this

/usr/AppServer/CDev/Sections.ear/sectionSite/all-listings

I would like to read a folder thats in another location on the same box.


/usr/DiffServer/sectionSite/small-site/sports-news

from my JSP I'm doing
<%
currDir= new File("/usr/DiffServer/sectionSite/small-site/sports-news");
for (File dirItem : currDir.listFiles()) {
out.print("items "+dirItem.getName());
}
%>

Ofcourse I get a null pointer. What am I doing wrong and if its possible how do I get the list of files under /sports-news folder?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66142
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java code in a JSP?

First step is to move that out of a JSP and into a Java class.

Second, what do you mean "of course"?

Check the path to the file, and check the permissions. There's nothing special about file I/O in a web app -- it follows all the same rules.
 
Nishad Banodkar
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can always use any folder on hard drive...if its outside your context, use full path to the folder, i.e. C:\...\...\... and so on.....
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!