Results 1 to 4 of 4
Thread: Filechecker in html via applet
- 12-04-2009, 06:23 PM #1
Member
- Join Date
- Dec 2009
- Posts
- 3
- Rep Power
- 0
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 ...
GKLast edited by gkirca; 12-22-2009 at 10:37 AM. Reason: Question
- 12-11-2009, 12:13 AM #2
Member
- Join Date
- Dec 2009
- Posts
- 3
- Rep Power
- 0
Hi community,
nobody with an idea?
Thanks in advance
GK
- 12-11-2009, 12:47 AM #3
Senior Member
- Join Date
- Dec 2009
- Location
- Belgrade, Serbia
- Posts
- 364
- Rep Power
- 4
Hello!
You want to write code and send it over net to someones PC
that can play around with his file system ?
You can't do that.
It is security issue!
It's up to the user to check it.
You will never be able to have direct interaction with the user's filesystem
using applets in this way (security issues can be changed on clients JVM but
dont want to mess with that)
So what CAN you do?
You wait for user to choose file from its filesystem.
When he does that, and BEFORE he submit form,
your AJAX function listens to this event all time, and when it happens
function send info about it to your server behind scenes.
find any ajax basic example for this
and i hope it will help you
regards :)
- 12-22-2009, 10:35 AM #4
Member
- Join Date
- Dec 2009
- Posts
- 3
- Rep Power
- 0
Fon,
Sorry for the late reply, I was a little busy in the last time.
Thanks for your response. I know of the behaviour and the security restrictions, but I just want to find out, if it is possible to find a way to get around this.
Meanwhile several colleagues told me the same. If I find a way (which I think will not happen), I'll update this thread.
Thanks, merry christmas and a happy new year to all, who are reading this :-)
Similar Threads
-
Two Form Applet in html
By barusk in forum Java AppletsReplies: 0Last Post: 03-16-2009, 05:36 PM -
Embedding Applet into HTML?
By Unome in forum Java AppletsReplies: 1Last Post: 02-21-2009, 03:40 AM -
Java Applet HTML
By ownlol in forum Java AppletsReplies: 4Last Post: 07-21-2008, 02:59 AM -
Chat Applet in HTML
By Flynazn in forum Java AppletsReplies: 3Last Post: 05-27-2008, 09:26 AM -
Create a Applet in the page HTML
By Daniel in forum Java AppletsReplies: 2Last Post: 07-04-2007, 07:52 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks