Making IE and a standalone Java application communicate...

Making IE and a standalone Java application communicate...

Post by Sharon M » Wed, 18 Aug 2004 16:01:38


Hi,

I would like to intercept an URL link clicked in IE and send the URL string
to a running Java application.

1. Is it possible to write an ActiveX control to be embedded in a web page
so that when an URL link is clicked in this web page, the ActiveX control
can be notified of the click and get the clicked URL string? For example,
this ActiveX control will register itself as a listener of the WebBroswer
control so that when a link is clicked, the ActiveX control is notified by
the WebBrowser control.

2. If the above is possible, can this ActiveX control in turn send the
intercepted URL string to an external application, in this case, a Java
application? When the Java application is started, is it possible to find
and connect to the ActiveX control so that it can register itself as a
listener?

Thanks in advance for any hints and tips/

Patrick Ma
 
 
 

Making IE and a standalone Java application communicate...

Post by Igor Tande » Thu, 19 Aug 2004 03:15:14


Yes it is possible.


Should be possible, but note that I don't know much about Java and
interprocess communication mechanisms it might support.
--
With best wishes,
Igor Tandetnik

"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken

 
 
 

Making IE and a standalone Java application communicate...

Post by Patrick M » Thu, 19 Aug 2004 05:28:41

Igor,

Thanks very much for the response.


Please verify if this is the correct approach.
1. Write a GUI-less ActiveX control.
2. Embed this control in a web page.
3. In the initialization code of the ActiveX control, it can register itself
as a listener of the *currently run IE instance*.
4. When a URL link is clicked in this instance of IE, the ActiveX control
will be notified.


There are Java to COM mechanism available that can let Java call COM and let
Java receive events from COM. One thing I am not sure is that given the
above ActiveX control, how can Java *find and connect* to it and register as
a event listener. In other words, is there an OS mechanism for a process to
find and connect to a running COM server?

Patrick Ma
 
 
 

Making IE and a standalone Java application communicate...

Post by Igor Tande » Thu, 19 Aug 2004 06:24:43


It does not really matter whether it has GUI or not. If you don't want a
GUI, by all means write a control without it.


Yes


Yes


Yes


Can Java application be a COM server?


Won't it be easier for the control to find and connect to the
application? You can have several controls running simultaneously (e.g.
in several IE instances), but only one Java app if I understand
correctly.


A component can register itself in the Running Object Table (ROT) - see
IRunningObjectTable.
--
With best wishes,
Igor Tandetnik

"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken
 
 
 

Making IE and a standalone Java application communicate...

Post by Patrick M » Thu, 19 Aug 2004 10:05:33

Igor,


Not being a Windows programmer, can you point me into the direction of how
the ActiveX control can find the running IE instance? Is the IE instance an
IWebBrowser? If it is, I think I can then look up the IWebBrowser interface
to see how to register the ActiveX control as a listener to the URL clicked
event (if there is such an event ).


I will find out.


Point taken. Thanks.


So, if my Java program can act as a COM server and register itself in ROT
when it starts up, then the ActiveX control can use the ROT to find the Java
program and invoke its API. Is this correct?

Thanks.

--
Patrick Ma
XXXX@XXXXX.COM
Cell 1-917-282-2528
 
 
 

Making IE and a standalone Java application communicate...

Post by Igor Tande » Thu, 19 Aug 2004 23:49:44


See KB Article KB172763 "INFO: Accessing the Object Model from Within an
ActiveX Control"


Or the other way round - each control can register itself in ROT, and
Java app can look them up there.

If you go with controls connecting to Java app, which is a regular COM
server, then a control can simply do CoCreateInstance to communicate to
(and start, if necessary) the server. No need for ROT in this case.
--
With best wishes,
Igor Tandetnik

"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken