|
I am new to javascript writing and need a bit of help. I am writing a .jsp web page.
I have a javascript function which is:
var fso;
var e;
var theFiles = new Array();
int fileCounter = 0;
var TristateFalse = 0;
var ForWriting = 2;
var ForReading = 1;
myActiveXObject = new ActiveXObject("Scripting.FileSystemObject");
dataFile = myActiveXObject.GetFile("distPath.dat");
text2 = dataFile.OpenAsTextStream(ForReading, TristateFalse);
filepath = text2.ReadLine( );
text2.Close( );
function findFiles() {
fso = new ActiveXObject("Scripting.FileSystemObject");
e = new Enumerator(fso.GetFolder(filepath).files);
for (e.moveFirst(); ! e.atEnd(); e.moveNext()) {
theFiles[fileCounter] = e.item();
fileCounter++;
}
}
I call the function via onload in the <body onload="findFiles();">
the function works, as I have validated that by adding document.writeln(theFiles[fileCounter]) in the above function and get the output I expect (all the files in the directory pointed to by the distPath.dat file.
my problem is I want to display the
theFiles[fileCounter] array data better so I coded a table as below:
<table border="0" cellspacing="1" cellpadding="2" align="center" width="100%">
<tr align="center" bgcolor="#EEEEEE" valign="top">
<td> Filename </td>
</tr>
<% for (int i=0;i< fileCounter ;i++) { %>
<tr align="center" bgcolor="#FFFFFF">
<td> <%= theFiles %></td>
</tr>
<% } %>
</table>
when loading the page I get these errors:
An error occurred at line: 128 in the jsp file: /passwordAdminViewValidUserIDlist.jsp
Generated servlet error:
fileCounter cannot be resolved
(line 128 is the <% for (int i=0;i< fileCounter ;i++) { %> line)
An error occurred at line: 130 in the jsp file: /passwordAdminViewValidUserIDlist.jsp
Generated servlet error:
theFiles cannot be resolved
(line 130 is the <td> <%= theFiles %></td>
line)
can any one help?
Thanks,
K
|
|
|
|
|
|
|
|