The Artima Developer Community
Sponsored Link

Java Answers Forum
Issue using java.io.File

1 reply on 1 page. Most recent reply: Mar 8, 2003 1:44 PM by Charles Bell

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Ajay Kalidindi

Posts: 1
Nickname: javahelper
Registered: Feb, 2003

Issue using java.io.File Posted: Feb 27, 2003 1:11 AM
Reply to this message Reply
Advertisement
Hi

Environment : Linux 7.2
JDK : 1.3
Tomcat : 4.1.18
APACHE : 1.3.27 (FYI)

I can not get the following code to work form a jsp page:

out.println("path : " + request.getContextPath());
File f = new File(request.getContextPath());
if (f.isDirectory()) {
out.println(f.getName()+" is directory");
}
File[] fs = f.listFiles();
if (fs != null) {
out.println(fs.length + "<BR>");
} else {
out.println("<BR>fs is null<BR>");
}
if (fs != null) {
int i;
for (i=0;i<fs.length;i++) {
out.println("<BR>"+fs.getName());
}
}

When I run the above code:

1. f is not null
2. fs is null
3. f.isDirectory is false
4. f.getAbsolutePath is /WEB-INF

basically I can not browse the directory structure.

Any help in this regard is appreciated.

Regards

Ajay Kalidindi


Charles Bell

Posts: 519
Nickname: charles
Registered: Feb, 2002

Re: Issue using java.io.File Posted: Mar 8, 2003 1:44 PM
Reply to this message Reply
You probably have your jsp file in the wrong folder.

Only the resource files you don't want users to be able to browse through should be under /WEB-INF

that is where you put class and jar files.
class files go under the /WEB-INF/classes folder
jars under the /WEB-INF/lib folder

Your jsp file will probably compile and run if you stick it under the webapps/ROOT folder.

Its got to be in a visible spot, the same as htm or html web page files.

If you are using the default Tomcat install, the index page (index.htm, index.html, index.jsp, default.htm, etc.) will come up if you ask for http://localhost:8080/

Add a link to the index page to your jsp to access it from the index page.

Flat View: This topic has 1 reply on 1 page
Topic: Word Frequency Data Previous Topic   Next Topic Topic: Help with Java menu

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use