Filechecker in html via applet
Hi all,
nobody out there with an idea on this?
I'm trying to implement a very little tool into my html code: a filechecker!
It's not possible to use javascript for this, if you want to support other browsers than IE (ActiveX!).
The html file I provide is a list of documents with an href set to the doc.
The html file should be accessed via web but locally (e.g. CD or USB stick) as well (thus should work without XMLHttprequest).
That's the intention!
Now my code, how I tried to solve the problem:
HTML code goes here >>>
<html>
<script type="text/javascript">
function fileChecker (fileName) {
var Test = document.applets["fileExist"].fileChecker(fileName);
if (Test == "true") {
document.write("exists");
}
else {
document.write("does not exists");
}
}
</script>
<applet code="FileChecker.class" name="fileExist"></applet>
<body>
.some.other.useless.things.
<p>Document titled 'Something' <a href="javascript:fileChecker("./directory/filename.zip")"</a>
...
</body>
</html>
<<< HTML code ends here >>>
Java code goes here >>>
import java.io.File;
import java.applet.Applet;
public class FileChecker extends Applet {
// serial ID has no effect
// private static final long serialVersionUID = 1L;
public boolean fileChecker(String fileName) {
boolean retcode = false;
File fileToCheck = new File(fileName);
System.out.println("File to check: " + fileName);
retcode = fileToCheck.exists();
return retcode;
}
}
<<< Java code ends here
The result is ... not as expected. I checked the java console (level 5), no errors nor any exceptions! But I even get no result in my html page!
Anybody has an idea?
Any hint very appreciated and thanks in advance ...
GK