LiveConnect javascript supports java.io.File but not FileReader?

Hello,

I am trying to port some Javascript from a Netscape 4.x environment to
Mozilla 1.4

(The code uses the "UniversalFileRead" privilege).

It appears that Mozilla currently only supports some of the java classes 
that used to be supported in Netscape's LiveConnect. For instance, in 
the simple test below, I am trying to read the contents of a text file.

I can construct a java.io.File object in javascript, and I can even call 
the getPath() method. However, I cannot then construct a
java.io.FileReader object which I need in order to read from the file.

(My attempt to access java.io.FileReader causes the following error
in the javascript console: Error: jsdIExecutionHook is not defined)

Since this worked for me in Netscape 4.x I am trying to understand
what this means for the code that I want to port.

Am I doing something wrong, or is it that the FileReader class is not
yet supported?

I would be grateful for any feedback.

- Simon Taylor

-------
<HTML>
<HEAD><TITLE>A simple js privileges test</TITLE></HEAD>
<BODY>
<h4>A simple js - java io test 2</h4>
<SCRIPT LANGUAGE="Javascript">
function ioTest()
{
     try {
 
netscape.security.PrivilegeManager.enablePrivilege("UniversalFileRead");
     } catch (err) {
         document.write('UniversalFileRead denied, error was: ' + err + 
'<br>');
	return false;
     }
     document.write("2. UniversalFileRead PASSED<BR>");
     document.write("3. java.io.File...<BR>");
     var file = new java.io.File("/tmp/file");
     document.write("  ...OK<br>");

     // test the getPath method
     document.write("4. getPath...<BR>");
     document.write("Can we read this file?: " + file.getPath() + "<br>");
     document.write("  ...OK<br>");

     // FileReader?
     document.write("5. FileReader?...<br>");
     var filereader = new java.io.FileReader(file);
     document.write("  ...OK<br>");
     document.write("9. ioTest done<BR>");
}

ioTest();
</SCRIPT>
</BODY>
</HTML>

0
Simon
7/20/2003 6:14:48 AM
netscape.mozilla.jseng 1530 articles. 0 followers. Follow

4 Replies
456 Views

Similar Articles

[PageSpeed] 54

Simon Taylor wrote:

> (My attempt to access java.io.FileReader causes the following error
> in the javascript console: Error: jsdIExecutionHook is not defined)

That is spurious: it has to do with the JS debugger, Venkman.  You 
should retry the test after disabling the debugger completely.  See 
http://www.mozilla.org/projects/venkman/ and please do file a bug at 
http://bugzilla.mozilla.org/.

Cc'ing rginda for his advice on how to disable the debugger.

> Since this worked for me in Netscape 4.x I am trying to understand
> what this means for the code that I want to port.
> 
> Am I doing something wrong, or is it that the FileReader class is not
> yet supported?

All classes that can be loaded should be supported.  There is no 
per-class list or glue code to regenerate.

There may well be a LiveConnect bug hiding here.

/be

> 
> I would be grateful for any feedback.
> 
> - Simon Taylor
> 
> -------
> <HTML>
> <HEAD><TITLE>A simple js privileges test</TITLE></HEAD>
> <BODY>
> <h4>A simple js - java io test 2</h4>
> <SCRIPT LANGUAGE="Javascript">
> function ioTest()
> {
>     try {
> 
> netscape.security.PrivilegeManager.enablePrivilege("UniversalFileRead");
>     } catch (err) {
>         document.write('UniversalFileRead denied, error was: ' + err + 
> '<br>');
>     return false;
>     }
>     document.write("2. UniversalFileRead PASSED<BR>");
>     document.write("3. java.io.File...<BR>");
>     var file = new java.io.File("/tmp/file");
>     document.write("  ...OK<br>");
> 
>     // test the getPath method
>     document.write("4. getPath...<BR>");
>     document.write("Can we read this file?: " + file.getPath() + "<br>");
>     document.write("  ...OK<br>");
> 
>     // FileReader?
>     document.write("5. FileReader?...<br>");
>     var filereader = new java.io.FileReader(file);
>     document.write("  ...OK<br>");
>     document.write("9. ioTest done<BR>");
> }
> 
> ioTest();
> </SCRIPT>
> </BODY>
> </HTML>
> 

0
Brendan
7/21/2003 2:19:01 AM
Thanks to everyone who has offered help.

We're still unable to run the get a LiveConnect script to work using the 
  FileReader object. (it fails for some other Java classes also, but I'm 
focussing on FileReader for the sake of simplicity).

I have one report from someone who says that the script does work for 
him with JRE 1.4.2 on Windows XP Prof. However, it won't work for us in 
any of the environments we've run it in, including Windows XP Prof (2002 
Service Pack 1).

Does anyone know of anything *new* in the environment that has to be set 
up in order for the full LiveConnect functionality to work?

In our tests, we are using the following line in the users pref.js file:

   user_pref("signed.applets.codebase_principal_support", true);

is that *all* that needs to be done?

Here is a summary of the platforms we've tested on, the code only works
for us in Netscape 4.x

Fails in:
   Windows XP Prof/Mozilla 1.4/JRE 1.4.2
   Windows 2000/Mozilla 1.4/JRE 1.4.2
   Red Hat Linux 8.0/Mozilla 1.4/JRE 1.4.2

Works in:
   Windows XP Prof/Netscape 4.x/JRE 1.4.2
   Windows 2000/Netscape 4.x/JRE 1.4.2
   Red Hat Linux 8.0/Netscape 4.8/JRE 1.4.2

Once again, I would be delighted to hear anyone's opinion.

Regards,

Simon Taylor

0
Simon
7/21/2003 2:40:14 AM
Simon Taylor wrote:
> Here is a summary of the platforms we've tested on, the code only works
> for us in Netscape 4.x
> 
> Fails in:
>   Windows XP Prof/Mozilla 1.4/JRE 1.4.2
>   Windows 2000/Mozilla 1.4/JRE 1.4.2
>   Red Hat Linux 8.0/Mozilla 1.4/JRE 1.4.2
> 
> Works in:
>   Windows XP Prof/Netscape 4.x/JRE 1.4.2
>   Windows 2000/Netscape 4.x/JRE 1.4.2
>   Red Hat Linux 8.0/Netscape 4.8/JRE 1.4.2
> 
Works in:
     Windows XP Prof
     Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4) Gecko/20030624
     JRE 1.4.1_01-b01

Please make sure that the file exists (the contructor will fail if it does not).

Piotr Lakomy

0
Piotr
7/22/2003 2:41:49 AM

Simon Taylor wrote:
> Thanks to everyone who has offered help.
> 
> We're still unable to run the get a LiveConnect script to work using the 
>  FileReader object. (it fails for some other Java classes also, but I'm 
> focussing on FileReader for the sake of simplicity).
> 
> I have one report from someone who says that the script does work for 
> him with JRE 1.4.2 on Windows XP Prof. However, it won't work for us in 
> any of the environments we've run it in, including Windows XP Prof (2002 
> Service Pack 1).
> 
> Does anyone know of anything *new* in the environment that has to be set 
> up in order for the full LiveConnect functionality to work?
> 
> In our tests, we are using the following line in the users pref.js file:
> 
>   user_pref("signed.applets.codebase_principal_support", true);
> 
> is that *all* that needs to be done?
> 
> Here is a summary of the platforms we've tested on, the code only works
> for us in Netscape 4.x
> 
> Fails in:
>   Windows XP Prof/Mozilla 1.4/JRE 1.4.2
>   Windows 2000/Mozilla 1.4/JRE 1.4.2
>   Red Hat Linux 8.0/Mozilla 1.4/JRE 1.4.2
> 
> Works in:
>   Windows XP Prof/Netscape 4.x/JRE 1.4.2
>   Windows 2000/Netscape 4.x/JRE 1.4.2
>   Red Hat Linux 8.0/Netscape 4.8/JRE 1.4.2
> 
> Once again, I would be delighted to hear anyone's opinion.

I think one problem you run into is that
   netscape.security.PrivilegeManager
with Mozilla is no longer capable of requesting privileges for Java 
code, at least that is my understanding. The PrivilegeManager is solely 
for requesting privileges for JavaScript code.
As for accessing files you might be able to achieve that without the use 
of Liveconnect Java calls but by using XPCOM after requesting 
UniversalXPConnect privileges.



-- 

	Martin Honnen
	http://JavaScript.FAQTs.com/

0
Martin
7/22/2003 11:42:03 AM
Reply:

Similar Artilces:

[RHINO/HTTPUNIT] org.mozilla.javascript.JavaScriptException: java.io.EOFException
Hi, I get the above error messaging during (httpunit-)parsing of the URL : https://portal.intersport.de/irj The stacktrace is: --------------------------------------------------------------------------- org.mozilla.javascript.JavaScriptException: java.io.EOFException at org.mozilla.javascript.JavaScriptException.wrapException(JavaScriptException.java:70) at org.mozilla.javascript.FunctionObject.call(FunctionObject.java:418) at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2179) at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:58) at...

java.io.NotSerializableException: org.mozilla.javascript.ClassCache (somewhat long)
If some one can take a look into this problem, I will appreciate it greately. I am trying to serialize simple JS Function. I do not think it have much relevance, but function I am trying to serialize looks like this: function () { this.result = this.a + this.b; return this.result; } This is a snipet of the code which I am using to serialize it. At this moment function in question stored in remote_method variable: .... Scriptable remote_method = ...; .... ByteArrayOutputStream baos = new ByteArrayOutputStream(); ScriptableOutputStream sos = new ScriptableOutputStre...

Problem with java.io.File.listFiles (Java in the database)
I have to implement a functionality to show client workstations the filestructure of the Database server. For that reason I intended to write a java class (see appendix) with a method that returns a comma separated list a) of subdirectories for a given root or b) a list of available hard disc devices if no root is named For that reason I used the listFiles() method of the java.io.File. But this method returns different results depending on the calling process. I implemeted a main method an starting this outside the database I get the correct results. When I import my class into...

This browser does not support Java or Java support has been disabled
When trying to access Java calendar in GW65 web access: "This browser does not support Java or Java support has been disabled." Works fine for Mozilla. Not for IE6. I'm sure it's a security setting in IE6. I'm not running SPYbot or anthing else like that in the background. Suggestions? Brian Brian, It appears that in the past few days you have not received a response to your posting. That concerns us, and has triggered this automated reply. Has your problem been resolved? If not, you might try one of the following options: - D...

does mozilla support javascript?
i am now under redhat9.0 when i browses some webpage i can not open some area in the page which wrote by javascript can i get some help my mozilla build id: 2003022516,Mozilla 1.2.1 thanks xuglei wrote: > i am now under redhat9.0 > when i browses some webpage i can not open some area > in the page which wrote by javascript > can i get some help > > my mozilla build id: 2003022516,Mozilla 1.2.1 Of course Mozilla supports JavaScript. 1. Your report is pretty useless without a testcase, or the URL of a page that doesn't work as you expect...

Using Rhino to invoke a javascript function (compiled to a java .class file) in Java code
This is a multi-part message in MIME format. ------_=_NextPart_001_01C66489.8E9FE41E Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi all, =20 I am new to Rhino and the documentation on the website and the newsgroups that I searched did not yield me the answer I was looking for, so I am posting here. I am sorry if this question has already been asked before. =20 I have a very basic problem which I couldn't find documentation on how to solve. I am simplifying the example here. Suppose I have a JS file with th...

Who's monkeying with the mozilla.support.seamonkey: record in my news.mozilla.com.rc file?
Every several months something corrupts the contents of the mozilla.support.seamonkey: record in the news.mozilla.com.rc file of my SM profile. All of a sudden, all of the unread articles in the newsgroup are marked as read. This happens in between news reading sessions. i.e. when I connect to the server the next time, the number of unread articles reported has dropped from whatever it was when I ended the previous reading session, down to only the number of new articles that have just arrived. If I open the .rc file with an editor, the record for the newsgroup has been modified to s...

java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException
iManager 2.7 on NW 6.5 SP7 seems to work OK, but I get this error on the logger screen Also Tomcat 5 will NOT unload clean, gives same error Anybody any idea Thanks Seb SEVERE: Exception loading sessions from persistent storage java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException : javax.servlet.http.Cookie at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1278) at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1603) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1271) ...

Support for avi files in Mozilla
Name: Prerit Email: preritdattaatgmaildotcom Product: Firefox Summary: Support for avi files in Mozilla Comments: I would like you to add some codec or feature to allow avi file to play in websites. Mozilla currently does not play it. Browser Details: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.7) Gecko/20100713 Ant.com Toolbar 2.0.1 Firefox/3.6.7 From URL: http://hendrix.mozilla.org/ Note to readers: Hendrix gives no expectation of a response to this feedback but if you wish to provide one you must BCC (not CC) the sender for them to see it. ...

async IO / large file support
Anyone tested throughput async IO on 2.4.18 kernel and the ASE 12.5 Dev. Edition ? I did, results were schocking to me: made datadevice and logdevice on a ext2 filesystem (2G devices!) made db on those devices made table with text field in it, bcp file of 233Mb with 65000 rows. Noticed thoughput of 100 rows/18 sec (packet size 16K, nr of pre-allocated extents=31,select into option). Noticed that installation of the developers edition puts a "DEFAULT" value on "allow sql server async i/o" in .cfg file instead of "0". Noticed the msg at startup in the...

Accessing Java from JavaScript IN (Mozilla) BROWSER???
Hello, I'm trying to use Java within JavaScript code in a HTML page in Mozilla. Well, var myString = new java.lang.String("Hello world"); works fine (ok, I had to switch the "enable Java" option in Mozilla before:) Now I want to use a class (static method) from my own .jar. I tried var foo = Packages.my.own.Stuff.myMethod("hi") but I always get "Packages.my.own.Stuff.myMethod is not a function" I think my .jar file is simply not found since I'm sure the method is there and the same error happens for any really non-exi...

Mozilla - Java
Using java v 1..2.0_02 and Mozilla (1.4) What files do I need to move to the mozilla directory from the java directory for java to work? I read somewhere I need to move stuff to the bin directory in Mozilla / firebird ...

Firefox mozilla do not support .mht files
Name: Vimal Kumar Email: vimalkumardot7atgmaildotcom Product: Firefox Summary: Firefox mozilla do not support .mht files Comments: I am a regular user of firefox mozilla. the only difficulty i face during use is, it do not save files as .mht. so i have to switch to internet explorer or opera just to save files. Regards Vimal Kumar Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 FBSMTWB From URL: http://hendrix.mozilla.org/ Note to readers: Hendrix gives no expectation of a response to this feedback but if you...

Create javascript file from java object
Hello, I want Java to create a new Javascript File for me. Based on an existing java object. How could I do that? Please have a look at this: http://stackoverflow.com/questions/13401005/create-javascript-file-from-java-object On Thursday, November 15, 2012 3:47:52 PM UTC-8, David Ifraimov wrote: > Hello, >=20 > I want Java to create a new Javascript File for me. Based on an existing= =20 > java object. How could I do that? >=20 > Please have a look at this: >=20 > http://stackoverflow.com/questions/13401005/create-javascript-file-from-j= ava-object ...

Web resources about - LiveConnect javascript supports java.io.File but not FileReader? - netscape.mozilla.jseng

LifeBox. (@LifeBox_EngInfo) on Twitter
Log in Sign up You are on Twitter Mobile because you are using an old version of Internet Explorer. Learn more here LifeBox. @ LifeBox_EngInfo ...

JavaScript - Wikipedia, the free encyclopedia
programming styles. JavaScript was formalized in the ECMAScript language standard and is primarily used in the form of client-side JavaScript ...

Safari 1.2
... support for standards, adds support for personal certificate authentication, and works with Java 1.4.2 to enable websites that rely on LiveConnect ...

New JavaScript Engine Module Owner
As you may know, I wrote JavaScript in ten days . JS was born under the shadow of Java, and in spite of support by marca and Bill Joy , JS in ...

Mozilla fixes 10 Firefox flaws, half seen as 'critical'
Mozilla Corp. has patched 10 vulnerabilities, half of them critical, in its open-source Firefox browser and plans to provide a matching update ...

Facebook Vibes outed in video calling code, related music service seems a lock
You never really know what you're onto until you look, but who knew "looking" involved "digging through source code?" Software guru Jeff Rose ...

Highly Critical Firefox Vulnerabilities Emerge
Mozilla has released a scad of security bulletins outlining many new vulnerabilities discovered in its Firefox browser. All users of the software ...

HiveLive Takes Web 2.0 Upscale
Social information sharing startup HiveLive launches their LiveConnect Community Platform today at the Defrag conference in Denver, but it’s ...

HiveLive — Companies — Gigaom Search
search Blog Events Coming up at Gigaom Editorial Events Meetups Webinars All events All webinars Follow us Follow @gigaom Become a fan Connect ...

Austrian ID card vulnerable to spoofing attack
A flaw in the Java applet of the Austrian ID card enables attackers to sign arbitrary data with their victim's qualified digital signature. The ...

Resources last updated: 11/29/2015 3:22:39 AM