Java Forum / General / March 2007
Are all Java applets Active X?
Z - 20 Feb 2007 16:54 GMT Every applet or JApplet that I create and run causes IE 7 to warn me that I am about to use Active X.
Is there a way to build/write applets and JApplets so that they do not make use of Active X and, thus, do not cause this warning? Or is it unavoidable?
Andrew Thompson - 20 Feb 2007 17:03 GMT > Every applet or JApplet that I create and run causes IE 7 to warn me > that I am about to use Active X. > > Is there a way to build/write applets and JApplets so that they do not > make use of Active X and, thus, do not cause this warning? If this is that Eolas patent thing, you might try writing the applet element using JavasCript, which supposedly avoids the user having to 'click OK' the applet.
>...Or is it > unavoidable? Or you might just launch the applet using web start*, to avoid this problem with IE, the problems the JS based solution will introduce for browsers with JS disabled, the next problem with IE, the problems with other browsers that have not yet been reported..
* <http://www.physci.org/jws/#jtest>
Andrew T.
Oliver Wong - 20 Feb 2007 17:27 GMT > Every applet or JApplet that I create and run causes IE 7 to warn me that > I am about to use Active X. > > Is there a way to build/write applets and JApplets so that they do not > make use of Active X and, thus, do not cause this warning? Or is it > unavoidable? Applets (and JApplets) and ActiveX are two completely unrelated technologies (one evidence of this is that Linux and Mac desktops typically have zero support for ActiveX whatsoever, and yet they have no trouble running Java Applets). The warning is thus misleading and leading you down a false trail.
- Oliver
Daniel Dyer - 20 Feb 2007 19:58 GMT >> Every applet or JApplet that I create and run causes IE 7 to warn me >> that [quoted text clipped - 11 lines] > down a > false trail. Isn't Sun's Java plugin for IE implemented as an ActiveX control?
Dan.
 Signature Daniel Dyer https://watchmaker.dev.java.net - Evolutionary Algorithm Framework for Java
Steven J. Sobol - 20 Feb 2007 20:26 GMT
> Isn't Sun's Java plugin for IE implemented as an ActiveX control? Yes, and the documented workarounds for ActiveX activation will work.
 Signature Steve Sobol, Professional Geek ** Java/VB/VC/PHP/Perl ** Linux/*BSD/Windows Victorville, California PGP:0xE3AE35ED
It's all fun and games until someone starts a bonfire in the living room.
Andrew Thompson - 20 Feb 2007 21:23 GMT > In article <op.tn2cfzkh8kx...@jack.local>, Daniel Dyer wrote: > > Isn't Sun's Java plugin for IE implemented as an ActiveX control? > > Yes, and the documented workarounds for ActiveX activation will work. Some of the earliest solutions I saw to this, involved *writing* the applet element using JS. Later solutions got more subtle and involved a single script placed in the head, whereas the page content itself did not require any changes.
I am guessing the latter solution has the JS navigating the page DOM, looking for applets (or other ActiveX controls) - either to directly enable them, or to remove and re-add them.
Note that while the latter solution degrades gracefully to 'just the way it is now', the earlier one risks showing no applet at all, should JS be disabled*.
I would strongly recommend using one of the later 'single script in the head' type solutions if you decide to go this way.
* No, I do not /know/ of anybody that would allow Java in their browser, but no JS.
Andrew T.
Steven J. Sobol - 21 Feb 2007 00:21 GMT >> In article <op.tn2cfzkh8kx...@jack.local>, Daniel Dyer wrote: >> > Isn't Sun's Java plugin for IE implemented as an ActiveX control? [quoted text clipped - 7 lines] > whereas the page content itself did not require > any changes. One of the simplest workarounds, and I believe this one is endorsed by Microsoft, is to create a container like a DIV and set the innerHTML attribute...
 Signature Steve Sobol, Professional Geek ** Java/VB/VC/PHP/Perl ** Linux/*BSD/Windows Victorville, California PGP:0xE3AE35ED
It's all fun and games until someone starts a bonfire in the living room.
Z - 21 Feb 2007 04:05 GMT > One of the simplest workarounds, and I believe this one is endorsed by > Microsoft, is to create a container like a DIV and set the innerHTML > attribute... DIV?
One more time, please, but in English!
Alex Hunsley - 21 Feb 2007 09:24 GMT >> One of the simplest workarounds, and I believe this one is endorsed by >> Microsoft, is to create a container like a DIV and set the innerHTML [quoted text clipped - 3 lines] > > One more time, please, but in English! He means DIV tag. http://www.htmlcodetutorial.com/_DIV.html
lex
Andrew Thompson - 21 Feb 2007 10:44 GMT > In article <1172006618.005820.53...@q2g2000cwa.googlegroups.com>, Andrew Thompson wrote: > >> In article <op.tn2cfzkh8kx...@jack.local>, Daniel Dyer wrote: [quoted text clipped - 5 lines] > > involved *writing* the applet element using > > JS. ...
> One of the simplest workarounds, and I believe this one is endorsed by > Microsoft, *
> ..is to create a container like a DIV and set the innerHTML > attribute... Do you have a reference for that? The only info. I could find at MS that dealt with 'Microsoft activex innerhtml' <http://msdn.microsoft.com/library/default.asp?url=/workshop/author/ dhtml/overview/activating_activex.asp>
*Every* one of those fixes was dependent on JS support.
* Oh, and 'recommended by MS'? You would have more chance of convincing me if you'd said 'recommended by Bozo the psychopath clown'.
Andrew T.
Steven J. Sobol - 21 Feb 2007 19:11 GMT That was the first page I looked at. I didn't point to it yesterday because I forgot where it was.
> *Every* one of those fixes was dependent > on JS support. Yup. No way around it.
> * Oh, and 'recommended by MS'? You would > have more chance of convincing me if you'd > said 'recommended by Bozo the psychopath > clown'. *shrug*
It is what it is. Although, for what it's worth, I completely understand why you posted that. :) The reason I'd pay attention to MS's recommendations is because they created ActiveX and a lot of their software uses it, so they have an incentive to make ActiveX work
:)
 Signature Steve Sobol, Professional Geek ** Java/VB/VC/PHP/Perl ** Linux/*BSD/Windows Victorville, California PGP:0xE3AE35ED
It's all fun and games until someone starts a bonfire in the living room.
Richard Maher - 21 Feb 2007 22:38 GMT Hi Steven,
> > *Every* one of those fixes was dependent > > on JS support. > > Yup. No way around it. Don't we cross the JS Rubicon when we decide to deploy applets? Is there a way to invoke an applet from html without JS in the middle? Sounds good.
Also, what browser security restrictions are needed before this pop-up pops up? Download ActiveX or just Run ActiveX or Something else?
If the DIV tag method defeats this check for ActiveX can it not also be used to launch malicious ActiveX controls in someone's browser? Is this part of the reason why so many disable JS?
Cheers Richard Maher
> That was the first page I looked at. I didn't point to it yesterday > because I forgot where it was. [quoted text clipped - 16 lines] > their software uses it, so they have an incentive to make ActiveX work > :) Lew - 21 Feb 2007 23:33 GMT > Don't we cross the JS Rubicon when we decide to deploy applets? Is there a > way to invoke an applet from html without JS in the middle? Sounds good. The normal way to invoke an applet from HTML is without Javascript.
- Lew
Richard Maher - 22 Feb 2007 11:57 GMT Hi Lew,
> The normal way to invoke an applet from HTML is without Javascript. Ok, I should have qualified my question along the lines of ". . .and having the applet methods at the disposal of something like a html form". I assume you're talking about a page that has liitle more than an Applet/Object tag(s) and from the moment init() is called the Applet (and Java proper) call the shots. (And maybe when the applet finishes.destroy() it loads another page that says good-night) Is that how most people architect Applets? Where the web browser is little more than a delivery tool for the application front end? No wonder start() and stop() don't seem to get much of a run :-(
I personnally love the idea! (But can see now why those who have adopted this strategy would be more than a bit pissed-off at having to, for the first time, enable Javascript in the browsers of anyone who will use their Applets :-( Surely, much succour can be found in this by those of the looney WebStart fringe :-)
Not that anyone's interested, but my personal preferences are: -
1) Stand alone application. (Absolutely nothing to do with a browser, or Web Server!) Java, .NET, C#, Powerbuilder, Delphi, 3GL (whatever) used to deliver a full function whiz-bang front-end, that shouldn't be constrained by the implementation idiosyncrasies and version foibles of a (many) Web Browser. And if Web Start is the answer for Application (as well as JVM) version rollout then all the better!
2) Java Applet that is just that (a little application) doesn't have to be signed (cos it does no file i/o and talks only back to the codebase server with sockets) HTML page just pimps the Applet via the browser and from then on it's all Java.
3) HTML form with Javascript doing all those wonderful things it does in addition to exposing all of my lovely Applet methods to Form triggered events and data. (Without having to watch the Browser and Server do little more than poxy IBM3270 emulation. "Submit" My arse!) Everything on the server is yours for the taking on-demand in a connection-oriented, authorized and context-rich environment!
So the consensus here appears to be (1) but everyone likes the Browser delivery mechanism (and if they can't trust applets, activeX controls (let alone Javascript) how are they going to trust WebStart? People will feel the same as they do about the light in the fridge.) So you think they'd jump at Applets but, rightly or wrongly, there is a feeling out there that Java is just too hard (like rollin' off a log if you ask me :-) and you have to pay Java developers oodles more than pizza-faced scripters.
My latest guess is, judging by the staffing levels and skills of your average it shop (and the fabulous things that can be done with just html and JS already), that option (3) would be the most appealing for many. HTML and Javascript is all they'll need to know. (That is, the Applet and the Application Server architecture is completely recyclable)
Anyway just my 2c.
Cheers Richard Maher
PS. If there are other ways of achieving client->tcp/ip-socket->server (without http or isapi or a.n.otherpileofpooh) then please put me out of my misery! The above three are the only ones I can think of. (That isn't exclusively single platform)
PPS. I don't think this activeX issue affects Windows2000 (judging by the code in the fix anyway) Is that right? Could be why I haven't seen this OK box yet. XP and Vista only?
PPPS. Anyone got a "little" example of a seperate Applet-spawned java thread interacting/co-existing/augmenting what's happening in the genesis inducing html page?
> > Don't we cross the JS Rubicon when we decide to deploy applets? Is there a > > way to invoke an applet from html without JS in the middle? Sounds good. > > The normal way to invoke an applet from HTML is without Javascript. > > - Lew Richard Maher - 20 Feb 2007 21:56 GMT Hi,
> > Isn't Sun's Java plugin for IE implemented as an ActiveX control? > > Yes, and the documented workarounds for ActiveX activation will work. Can someone please tell me what exactly "Sun's Java plugin for IE" is, and why someone would use it over and above whatever Microsoft ship's with IE already?
Is it also going away when MS pulls support for their JVM?
Is it the bit of code that loads Applets from the codebase (which would explain a lot of things)
I have downloaded and am running Sun's SDK 1.6 with the Java HotSpot client VM on Windows2000 IE 6. Did I have to do something different to get this "plugin"?
Is it only IE7? This really sounds disgusting :-(
Anyone got a reference for the "documented workarounds"?
Cheers Richard Maher
PS. Sorry if this has been discussed before. I'm always a bit late.
Oliver Wong - 20 Feb 2007 22:49 GMT > Hi, > [quoted text clipped - 5 lines] > why someone would use it over and above whatever Microsoft ship's with IE > already? I'm a bit hesitant to jump into this, as it looks like I was wrong about browser architecture before, but...
Most webbrowsers need plugins to handle various content types. For example, there's a "Flash" plugin made by Macromedia for handling Flash content (you've seen Flash content if you've ever used YouTube to view movies, for example). You download the plugin, it integrates with your browser (whether IE, netscape-based (e.g. FireFox), or Opera) and then your browser can now display Flash content.
Similarly, you need a Java plugin to display Java applets in your browser. Unlike Flash, a couple of companies has "competing" plugins that all supprot Java. Sun has one such plugin, and Microsoft used to have a plugin, but I think they discontinued it when they discontinued their JVM.
I haven't used IE7 much, but from my understanding, Microsoft does not ship a Java plugin at all with their browsers (not anymore, anyway -- they used to ship their own JVM a couple of years ago, but as you've noted, it's been discontinued). So you need to get the plugin from somewhere, and Sun's plugin is the most commonly used one.
> Is it also going away when MS pulls support for their JVM? I think Sun has no plans to discontinue their Java products, including their Java plugin (meaning it'll probably stick around for a while). Sun also said they'll release their implemention as open source and when that happens, you're guaranteed that it will never "go away".
> Is it the bit of code that loads Applets from the codebase (which would > explain a lot of things) Yes.
> I have downloaded and am running Sun's SDK 1.6 with the Java HotSpot > client > VM on Windows2000 IE 6. Did I have to do something different to get this > "plugin"? When you install the SDK, it also installs the JRE as a sub-step of the installation process. The plugin is included in the JRE, so you should have the plugin now.
> Is it only IE7? This really sounds disgusting :-( I'm gonna avoid this question, since it seems like I don't know as much about ActiveX as I thougth I did.
> Anyone got a reference for the "documented workarounds"? Try:
http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/overvie w/activating_activex.asp http://activecontent.blogspot.com/
- Oliver
Daniel Dyer - 20 Feb 2007 23:15 GMT > Can someone please tell me what exactly "Sun's Java plugin for IE" is, > and > why someone would use it over and above whatever Microsoft ship's with IE > already? The Java plugin is part of the Java runtime distribution. The plugin itself is a wrapper around the Java virtual machine. As far as I am aware, there are two plugins - both wrapping the same JVM. One is an ActiveX control and is used by Internet Explorer. The other is a plugin that conforms to the Netscape/Mozilla plugin interface and is used by Mozilla-based browsers. Opera used to use the Netscape plugin, I'm not sure if they still do (they were at some point, on Linux at least, launching the JVM directly).
Microsoft's JVM is compatible (mostly) with version 1.1 of Java. 1.1 is ten years old, 6.0 being the most recent version. 1.1 lacks many core library classes that we have been taking for granted for years, most significantly the Collections Framework and Swing. Without Swing you are effectively restricted to GUIs built using AWT, which provides only basic UI widgets (no tables, trees, tabs, split panes etc.). Without the Collections Framework you either have to use the limited collections classes available (Vector and Hashtable) or write your own. You may also have trouble using 3rd party libraries since many will have API dependencies on the Collection/List/Set/Map interfaces.
> I have downloaded and am running Sun's SDK 1.6 with the Java HotSpot > client > VM on Windows2000 IE 6. Did I have to do something different to get this > "plugin"? No, it's bundled with it. You may have to change the settings in the control panel to determine which browsers use it.
Dan.
 Signature Daniel Dyer https://watchmaker.dev.java.net - Evolutionary Algorithm Framework for Java
Daniel Dyer - 20 Feb 2007 23:18 GMT > You may also have trouble using 3rd party libraries since many will have > API dependencies on the Collection/List/Set/Map interfaces. And even if they aren't, they are probably compiled with a more recent class file format that the Microsoft VM doesn't understand.
Dan.
 Signature Daniel Dyer https://watchmaker.dev.java.net - Evolutionary Algorithm Framework for Java
Steven J. Sobol - 21 Feb 2007 00:25 GMT > Can someone please tell me what exactly "Sun's Java plugin for IE" is, and > why someone would use it over and above whatever Microsoft ship's with IE > already? Microsoft Java is based on the JDK 1.1.x VM.
> Is it also going away when MS pulls support for their JVM? No, it's not; it's a Sun product, not a Microsoft product.
> Is it the bit of code that loads Applets from the codebase (which would > explain a lot of things) Yes, that's done by the Java plugin.
> I have downloaded and am running Sun's SDK 1.6 with the Java HotSpot client > VM on Windows2000 IE 6. Did I have to do something different to get this > "plugin"? If you don't have it installed, go to Sun's consumer website at java.com to download the browser plugin.
> Is it only IE7? This really sounds disgusting :-( No, it's IE6 too, and it was done because Microsoft didn't want to pay Eolas for the patents they have on automated ActiveX component activation. It's a legal issue, not a technical one, and I doubt M$ would have done it if they didn't have to to avoid paying Eolas tons of money.
> Anyone got a reference for the "documented workarounds"? Google "activex activation", and start here:
http://support.microsoft.com/kb/555662 (Related to Visual Studio but is relevant to any HTML page, even a hand-coded page)
The solution documented in that KnowledgeBase article should work with IE and still maintain compatibility with all other modern web browsers.
 Signature Steve Sobol, Professional Geek ** Java/VB/VC/PHP/Perl ** Linux/*BSD/Windows Victorville, California PGP:0xE3AE35ED
It's all fun and games until someone starts a bonfire in the living room.
Andrew Thompson - 21 Feb 2007 10:57 GMT ...
> http://support.microsoft.com/kb/555662 (Related to Visual Studio but > is relevant to any HTML page, even a hand-coded page) ..and particularly relevant to my earlier warning about writing the entire element using JS.
To quote the help page..
" .. 3) document.write('<OBJECT id="myControl1" name="myControl1" classid="WindowsActiveX.dll#WindowsActiveX.WindowsUserControl" width=600 height=272 > </OBJECT>');' "
Andrew T.
Steven J. Sobol - 21 Feb 2007 19:12 GMT > ..and particularly relevant to my earlier warning > about writing the entire element using JS. There is no way to circumvent the activation problem without using JS.
Except uninstalling the hotfix that patched IE to require activation, and that only works with IE6 and the patch would probably (as M$ mentions) just get reinstalled later as part of a "rollup".
 Signature Steve Sobol, Professional Geek ** Java/VB/VC/PHP/Perl ** Linux/*BSD/Windows Victorville, California PGP:0xE3AE35ED
It's all fun and games until someone starts a bonfire in the living room.
Andrew Thompson - 21 Feb 2007 19:34 GMT > In article <1172055442.692340.17...@k78g2000cwa.googlegroups.com>, Andrew Thompson wrote: > > ..and particularly relevant to my earlier warning > > about writing the entire element using JS. > > There is no way to circumvent the activation problem without using JS. Agreed. But I think you are missing my point about *writing* the element using JS.
The 'better solutions' I was referring to, would leave a page 'no more damaged' than it currently is (by the MS reaction to the Eolas patent) should JS was not enabled, whereas the MS 'solution' would have the entire element (and any associated alt or 'no java' section) vanish completely.
This is probably not a great worry for MS, since JS is (or at least was) so hard to disable in IE. In most other browsers, disabling scripting is simple.
Andrew T.
Steven J. Sobol - 21 Feb 2007 23:41 GMT > This is probably not a great worry for MS, > since JS is (or at least was) so hard to > disable in IE. In most other browsers, > disabling scripting is simple. JS is not terribly hard to disable - it's on the Security tab, you just have to do a little digging to find the proper setting.
 Signature Steve Sobol, Professional Geek ** Java/VB/VC/PHP/Perl ** Linux/*BSD/Windows Victorville, California PGP:0xE3AE35ED
It's all fun and games until someone starts a bonfire in the living room.
Richard Maher - 21 Feb 2007 13:28 GMT Hi Steven,
Thanks for the reply.
> > Is it the bit of code that loads Applets from the codebase (which would > > explain a lot of things) > > Yes, that's done by the Java plugin. So maybe that's why IE asks for my Archive file 3x with http and 7x with ftp yet the Appletviewer only ever asks once regardless of the protocol?
> http://support.microsoft.com/kb/555662 (Related to Visual Studio but > is relevant to any HTML page, even a hand-coded page) > > The solution documented in that KnowledgeBase article should work with > IE and still maintain compatibility with all other modern web browsers. At the moment I'm not experiencing this problem so maybe I don't have IE912945 installed on my IE6. (I had a quick look and couldn't see anything other than SP4 Rollup 1. I'll look for updates this weekend.) But I'm not doing anything with ActiveX controls so maybe it doesn't affect me? But then:-
"Steven J. Sobol" <sjsobol@JustThe.net> wrote in message news:slrnetmmci.bhi.sjsobol@amethyst.justthe.net...
> In article <op.tn2cfzkh8kxvgr@jack.local>, Daniel Dyer wrote: > > > Isn't Sun's Java plugin for IE implemented as an ActiveX control? > > Yes, and the documented workarounds for ActiveX activation will work. So we're *all* affected right? I should be seeing some pop-up asking me to accept activeX controls right? "From KB555662 forth, anyone running an Applet has to incorporate this DIV processing in their html to get around this pop-up" Is that right?
Cheers Richard Maher
> > Can someone please tell me what exactly "Sun's Java plugin for IE" is, and > > why someone would use it over and above whatever Microsoft ship's with IE [quoted text clipped - 35 lines] > The solution documented in that KnowledgeBase article should work with > IE and still maintain compatibility with all other modern web browsers. Steven J. Sobol - 21 Feb 2007 19:13 GMT > So maybe that's why IE asks for my Archive file 3x with http and 7x with ftp > yet the Appletviewer only ever asks once regardless of the protocol? Not sure, actually...
> So we're *all* affected right? I should be seeing some pop-up asking me to > accept activeX controls right? "From KB555662 forth, anyone running an > Applet has to incorporate this DIV processing in their html to get around > this pop-up" Is that right? Yes.
Personally, I think M$ could have ponied up the licensing fees and avoided all this, considering that they're worth billions of dollars. :(
 Signature Steve Sobol, Professional Geek ** Java/VB/VC/PHP/Perl ** Linux/*BSD/Windows Victorville, California PGP:0xE3AE35ED
It's all fun and games until someone starts a bonfire in the living room.
Chris Uppal - 21 Feb 2007 09:38 GMT > Can someone please tell me what exactly "Sun's Java plugin for IE" is, and > why someone would use it over and above whatever Microsoft ship's with IE > already? That suggests that you may currently be relying on MS's implementation of Java for your applets. If so then the relationship between Java and JavaScript may be closer than you'll find it easy to achieve otherwise[*]. I don't know for sure if that's true -- this is just a warning to check your design (discussed in other threads here) to see if it's still practical when using a real JVM/plug-in.
-- chris
[*] If my distant memory is correct, the MS JVM exposes all Java classes as COM objects, and their JavaScript implementation can call COM directly. Neither are true in other environments.
Richard Maher - 21 Feb 2007 13:10 GMT Hi Chris,
Before responding to your post (and going to bed) can I ask you a quick question: -
I'm calling my Applet like this 'var chan = document.getElementById("myApplet")' and inside my class definition that extends applet I have a variable "pipe" that is an instance of the Tier3Socket class and I want JavaScript to be able to invoke methods in "pipe" and I am getting a null pointer error if I try and say "byte_count = chan.pipe.readMessage(2)".
a) Can I only call public methods at the Applet Class level from JS? (No big deal) b) If I say "var getClass = chan.pipe" can I then invoke getClass.xxx() methods? c) Is it just that I haven't said "public" when I declared "Tier3Socket pipe;" (What is the default anyway?)
I will try it out but If you've got time to reply then please do.
> That suggests that you may currently be relying on MS's implementation of Java > for your applets. If so then the relationship between Java and JavaScript may > be closer than you'll find it easy to achieve otherwise[*]. I don't know for > sure if that's true -- this is just a warning to check your design (discussed > in other threads here) to see if it's still practical when using a real > JVM/plug-in. Everything I'm looking at (control panel, console etc) says "Sun Microsystems Inc. Java HotSpot Client VM 1.6.0-b105"; short of running Microsofts MSJVM remover tool, I don't know what else to do. Then Daniel Dyer said this: -
[As far as I am aware, there are two plugins - both wrapping the same JVM. One is an ActiveX control and is used by Internet Explorer. The other is a plugin that conforms to the Netscape/Mozilla plugin interface and is used by Mozilla-based browsers.]
This would explain the difference between my Appletviewer retrieval of the JAR file and that of IE. But hey I just want to get this working (hopefully by this weekend) and if you would be kind enough to look over the code then, I would be more than happy if you could point out dependencies and where it will fall over in a screaming heap :-)
Cheers Richard Maher
> > Can someone please tell me what exactly "Sun's Java plugin for IE" is, and > > why someone would use it over and above whatever Microsoft ship's with IE [quoted text clipped - 12 lines] > objects, and their JavaScript implementation can call COM directly. Neither > are true in other environments. Chris Uppal - 21 Feb 2007 14:16 GMT > I'm calling my Applet like this 'var chan = > document.getElementById("myApplet")' and inside my class definition that [quoted text clipped - 9 lines] > c) Is it just that I haven't said "public" when I declared "Tier3Socket > pipe;" I don't really know, I'm afraid. If the Live Connect guide I'm looking at is at all relevant (I don't know for sure that you are usng Live Connect, or even if LC still exists !), then the answer to (b) /should/ be "yes". Other than that, I'm guessing, but I wouldn't be at all surprised if the answer to all three questions was "yes" -- but that's only because that's how I'd have designed it, not because I know how the JS integration actually works.
(BTW (c) confused me a little, I'm assuming that you have just choosen "getClass" as the arbitrary name for a variable, you're not attempting to call the pipe object's getClass() method.)
It might sound silly, but is there any chance that your applet's "pipe" field actually /is/ null ? It's worth adding some tracing or something just to double check...
> (What is the default anyway?) The default for classes, fields, and methods is so-called "package private", which means that the class, field, or method isn't supposed to be visible from outside its own package -- JS doesn't /have/ to honour that (it could just ignore it, since Java protections don't apply if you are using JNI), but I'd guess that the designers would attempt to mimic Java semantics as far as they could and so they won't expose non-public members.
> Everything I'm looking at (control panel, console etc) says "Sun > Microsystems Inc. Java HotSpot Client VM 1.6.0-b105"; short of running > Microsofts MSJVM remover tool, I don't know what else to do. Sounds good. If you want to double-check, there's a system property ("java.vendor") you can check from your applet code to see the maker of the JVM you are actually running in (as opposed to the one that's installed and you /hope/ you are running in ;-). There's an example here: http://www.javaworld.com/javatips/jw-javatip53.html
One other thing. I have just found this on the Web. It's clearly long out of date, but it may still be relevant or even correct. http://www.unix.org.ua/orelly/web/jscript/ch19_07.html If it is then that may explain your problems too. (Easy way to check: run your applet under FireFox and see what changes...)
-- chris
Daniel Dyer - 21 Feb 2007 14:29 GMT >> I'm calling my Applet like this 'var chan = >> document.getElementById("myApplet")' and inside my class definition that [quoted text clipped - 21 lines] > three questions was "yes" -- but that's only because that's how I'd have > designed it, not because I know how the JS integration actually works. LiveConnect is definitely still around. A colleague and I used it recently for a rather ugly proof-of-concept to get a Flash movie and a Java applet to communicate with each other via JavaScript. It took a bit of debugging to get it working across browsers (each seems to have a different way of getting a reference to the applet in JavaScript), but we managed to get it working on the latest versions of IE, Firefox, Opera and Safari.
As far as I am aware, you can only invoke public methods on the applet.
Dan.
 Signature Daniel Dyer http://www.uncommons.org
Richard Maher - 21 Feb 2007 22:07 GMT Hi Daniel,
> As far as I am aware, you can only invoke public methods on the applet. Ok, I'll do that. BTW. No LiveConnect. (At least I haven't explicitly asked for it and don't know what it is/does :-)
Cheers Richard Maher
On Wed, 21 Feb 2007 14:16:27 -0000, Chris Uppal <chris.uppal@metagnostic.REMOVE-THIS.org> wrote:
> Richard Maher wrote: > [quoted text clipped - 23 lines] > three questions was "yes" -- but that's only because that's how I'd have > designed it, not because I know how the JS integration actually works. LiveConnect is definitely still around. A colleague and I used it recently for a rather ugly proof-of-concept to get a Flash movie and a Java applet to communicate with each other via JavaScript. It took a bit of debugging to get it working across browsers (each seems to have a different way of getting a reference to the applet in JavaScript), but we managed to get it working on the latest versions of IE, Firefox, Opera and Safari.
As far as I am aware, you can only invoke public methods on the applet.
Dan.
 Signature Daniel Dyer http://www.uncommons.org
Richard Maher - 21 Feb 2007 22:07 GMT Hi Chris,
As always (and everyone) thanks for the replies.
> (BTW (c) confused me a little, I'm assuming that you have just choosen > "getClass" as the arbitrary name for a variable, you're not attempting to call > the pipe object's getClass() method.) No, I'm attempting to call the pipe object's getClass() method :-) Silly huh?
I'll move a few public methods up to the Applet class to do what I want.and see what happens.
Cheers Richard Maher
> > I'm calling my Applet like this 'var chan = > > document.getElementById("myApplet")' and inside my class definition that [quoted text clipped - 51 lines] > > -- chris Richard Maher - 01 Mar 2007 22:10 GMT Hi Chris,
{A brief recap} I'm the guy that knows very little of Java/Javascript/html and have been wanting to open up a socket with Applets back to my VMS server and interact with the html/Javascript form. . .
I said: -
> But hey I just want to get this working (hopefully > by this weekend) and if you would be kind enough to look over the code then, > I would be more than happy if you could point out dependencies and where it > will fall over in a screaming heap :-) On the off chance you (and others) have absolutely nothing better to do this week-end, I have followed through on my threat to publish the code I've been working on all this time. I will include the main Applet and html/Javascript here but the wrapping and formatting will really screw it up so if anyone's has a passing interest, they can find a better copy at the end of this thread: - http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1071300
The last two post of mine 27/28 Feb have attachments and explain it all.
I think it's pretty sexy and does what I (and I can't see why not everyone else) wants, but if you could point out any architectural disasters like Threading Issues (Synchronization? Serializable), Memory Leaks etc I would *really* appreciate it! I don't care if I should be using Swing (or a.n.other) instead of AWT and I will get around to tightening up what doesn't need to be public to private, but I more interested here in what might be fundamentaly crap as opposed to what's not pretty. Me? I think it's sh.t hot!
Cheers Richard Maher
CornuCopiae.java ================
import java.applet.Applet; import java.awt.*; import java.net.*; import java.io.IOException;
public class CornuCopiae extends Applet { private String username = ""; private String password = ""; private boolean pass = false; public Tier3Socket pipe; public String stringOut = ""; public int bytesIn;
public void init() { if (!authorize()) { try { getAppletContext().showDocument (new URL (getCodeBase()+"accessdenied.html"),"_top"); } catch (Exception e) {e.printStackTrace(); } } }
public boolean authorize() { int port = Integer.parseInt(getParameter("PORT")); int maxBuf = Integer.parseInt(getParameter("MAXBUF")); String appl = getParameter("APPLICATION"); String hostCharSet = getParameter("HOSTCHARSET");
pipe = new Tier3Socket(getCodeBase().getHost(), port, maxBuf, hostCharSet);
System.out.println("Step 3");
try {pipe.open();} catch (Exception e) {return false;} System.out.println("Step 4");
Object parentFrame = getParent(); while ((parentFrame != null) && !(parentFrame instanceof Frame)) { parentFrame = ((Component)parentFrame).getParent(); }
Frame creds = (Frame)parentFrame;
Tier3Logon logon = new Tier3Logon(creds);
requestFocus();
if (logon.logonAborted) { System.out.println("Logon Aborted"); } else { username = logon.inUser.getText(); password = logon.inPass.getText();
pass = true; try {pipe.handShake(username, password);} catch (Exception e) { pass = false; e.printStackTrace(); System.out.println("Logon Failed"); } }
if (pass && logon.cb.getState()) { Tier3Welcome welcome = new Tier3Welcome(creds, appl, pipe.t3IdBuf); requestFocus(); welcome.dispose(); }
logon.dispose();
System.out.println("Step 5"); return pass; }
public void sendMessage (String message) { try {pipe.sendMessage(message);} catch (IOException e) {return;} }
public void sendUrgentData (int oob) { try {pipe.sendUrgentData(oob);} catch (IOException e) {return;} }
public int readMessage () throws IOException { try {bytesIn = pipe.readMessage();} catch (IOException e) {return 0;}
return bytesIn; } public int readMessage (int bytes) throws IOException { try {bytesIn = pipe.readMessage(bytes);} catch (IOException e) {return 0;}
return bytesIn; }
public String getString (int offset, int length) { try {stringOut = pipe.getString(offset, length);} catch (ArrayIndexOutOfBoundsException e) {return null;}
return stringOut; }
public void destroy() { try {pipe.close();} catch (IOException e) {e.printStackTrace();}
super.destroy(); }
}
Example1.html =============
<html>
<head>
<title> Example Client for Tier3 demo queue-lookup server Author: Richard Maher </title>
<style>
h2 { color: Turquoise; }
p.credits { color: Turquoise; }
.green_screen { color: Lime; background-color: Black; font-family: courier; }
</style>
<script type="text/javascript">
function enter(nextfield) { if (window.event && window.event.keyCode == 13) { nextfield.focus(); return false; } else return true; }
function num_only(numObj) { if (isNaN(numObj.value)) { numObj.value = ""; alert("Numeric value required"); numObj.focus(); return false; } else return true; }
function job_lookup() { if (!num_only(document.getjobs.entry_number)) return true;
var recTypeLen = 2; var recType = ""; var msgGetInfo = "10"; var jobInfo = "11"; var errorInfo = "00";
var zeroFill = "0000"; var maxRows = "9999"; var outPad = ""; var ok = true;
var selectRef = document.getjobs.job_list; var msgEntry = "";
selectRef.options[0].selected=true; var holdHdr = selectRef.options[0];
while (selectRef.options.length > 0) { selectRef.remove(selectRef.options[0]); } selectRef.options[0] = holdHdr document.getjobs.job_list.size = 1;
msgEntry = document.getjobs.entry_number.value; outPad = zeroFill.substring(0, (zeroFill.length - msgEntry.length));
var chan = document.getElementById("CornuCopiae"); chan.sendMessage(msgGetInfo.concat(outPad,msgEntry,maxRows));
if (chan.readMessage(recTypeLen) != recTypeLen) { alert ("Error receiving reply from server"); return false; } recType = chan.getString(0,recTypeLen);
if (recType == jobInfo) { ok = process_jobs(chan); } else { if (recType == errorInfo) { ok = process_error(chan); } else { alert ("Unknown message type " + recType); return false; } }
if (!ok) return false;
document.getjobs.entry_number.focus();
return true; }
function process_error(chan) { document.getjobs.rec_count.value = 0;
var errMsgLen = 0; var errLenLen = 3; var alertMsg = "Error retrieving job entry information\n";
if (chan.readMessage() < errLenLen) { alert ("Error receiving Error Length from server"); return false; }
errMsgLen = parseInt(chan.getString(0,errLenLen),10); alertMsg = alertMsg + chan.getString(errLenLen,errMsgLen); alert(alertMsg);
return true; }
function process_jobs(chan) { var recTypeLen = 2; var recType = ""; var jobInfo = "11"; var eofInfo = "99"; var eofLen = 3; var jobMsgLen = 109; var jobMsg = ""; var rc = 1; var eofInfo = "99"; var selectRef = document.getjobs.job_list;
for (;;) { rc = rc + 1; if (rc < 6) document.getjobs.job_list.size = rc;
if (chan.readMessage(jobMsgLen) != jobMsgLen) { alert ("Error receiving Job Information from server"); return false; }
jobMsg = chan.getString(0,4) + "|" + chan.getString(4,39) + "|" + chan.getString(43,15) + "|" + chan.getString(58,31) + "|" + chan.getString(89,10) + "|" + chan.getString(99,10); selectRef.options[selectRef.options.length] = new Option (jobMsg);
if (chan.readMessage(recTypeLen) != recTypeLen) { alert ("Error receiving reply from server"); return false; }
recType = chan.getString(0,recTypeLen); if (recType != jobInfo) break; }
if (recType != eofInfo) return false;
if (chan.readMessage(eofLen) != eofLen) { alert ("Error receiving reply from server"); return false; }
document.getjobs.rec_count.value = (rc - 1);
return true; }
</script>
</head>
<body>
<h2>Example Client for Tier3 DEMO application server on VMS</h2><hr>
<form name="getjobs">
<object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" width= "0" height= "0" name="CornuCopiae" id="CornuCopiae"> <param name="archive" value="tier3.jar"> <param name="codebase" value="http://1.2.3.6/"> <param name="code" value="CornuCopiae"> <param name="mayscript" value="yes"> <param name="scriptable" value="true"> <param name="name" value="CornuCopiae"> <param name="PORT" value="1024"> <param name="HOSTCHARSET" value="ISO-8859-1"> <param name="MAXBUF" value="512"> <param name="APPLICATION" value="DEMO">
</object>
<br />Enter Job Entry Number [Default is All jobs]: <input type="text" onkeypress="return enter(document.getjobs.send)" name="entry_number" maxlength=4 size=4 dir="rtl" />
<input type="button" onmouseup="job_lookup()" name="send" value="Get Job Info." />
Jobs Found: <input type="text" name="rec_count" readonly value="0" size=5 />
<br /><br />
<select name="job_list" id="Job_list" class="green_screen" size=1> <option value="lovhdr" selected=true disable=true > Nbr--Job-Name--------------------------------Job Status------Queue Name----------------------Queue Type-Status----</option> </select>
<br />
</form>
<p> This is an example of a browser-based, html and JavaScript, client interacting with a VMS hosted Tier3 Application Server in a connection-oriented and context-rich environment.<br /><br />
You would have noticed that, when this page was initially displayed, you were immediately prompted for your VMS Username and Password. Once authorization is successful your credentials, and an accompanying Persona, are automatically made available to your 3GL User Action Routines each time their Server Process is chosen to perform work on behalf of the client. In this example, the user only gets to see those Print and Batch jobs that they have privileges to view. You can find the corresponding server code for this example (demo_uars.cob) in your t3$examples directory.<br /><br />
The session and server connection are terminated when you change web pages or refresh this page. </p>
<hr>
<p class="credits"> "Tier3" is a registered trademark of Tier3 Software Ltd<br /> "CornuCopiae" is a trademark of Richard Maher </p>
</body> </html>
> Hi Chris, > [quoted text clipped - 71 lines] > Neither > > are true in other environments. Andy Dingley - 21 Feb 2007 12:49 GMT > Every applet or JApplet that I create and run causes IE 7 to warn me > that I am about to use Active X. So don't use IE....
This is a bogus piece of crap invented when M$oft threw their toys out of the pram after falling out with Sun. Although Java is unrelated to ActiveX, M$oft's IE implementation of support for it conflates and confuses the two.
There are well-documented work-arounds, but they're fairly sucky HTML and shouldn't be used blindly, for risk of confusing other browsers.
* If it's your own browser, upgrade away from IE.
* If it's an intranet, set up the trust settings to trust yoru servers.
* If it's teh intawebs, switch to Java Web Start, rather than applets.
Steven J. Sobol - 21 Feb 2007 19:15 GMT >> Every applet or JApplet that I create and run causes IE 7 to warn me >> that I am about to use Active X. > > So don't use IE.... And tell millions of people not to use IE too...
> This is a bogus piece of crap invented when M$oft threw their toys out > of the pram after falling out with Sun. I think *that's* irrelevant, as even if they were still in bed with Sun, the Java2 browser plugin for IE would probably still use ActiveX.
 Signature Steve Sobol, Professional Geek ** Java/VB/VC/PHP/Perl ** Linux/*BSD/Windows Victorville, California PGP:0xE3AE35ED
It's all fun and games until someone starts a bonfire in the living room.
Free MagazinesGet these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...
|
|
|