This Question is Answered

2 "helpful" answers available (2 pts)
2 Replies Last post: Dec 29, 2009 7:22 AM by Lyndsey  
Lyndsey   2 posts since
Dec 22, 2009
Currently Being Moderated

Dec 22, 2009 11:17 PM

Clear a cookie using OleContainer Automation

 

 

 

Hello,



 

 

I am trying to remove/clear a cookie when a user logs out of my application.  We depend on ComfyJ and we do not use JExplorer.  I am not particularly familiar with COM, so forgive me if this seems like a basic question...

 

The first step I need to accomplish is to get the HTMLDocument2 from my OleContainer (called "container" below).  From there I can worry about getting/setting the cookie.  I have created the container previously and used automation to call "Navigate2" with a given URL.



 

 

IDispatch dispatch = new IDispatchImpl();    //should this just be null?
 
Automation automationDoc = new Automation(container.getOleObject());
automationDoc.invoke("Document", new Object[] {dispatch});    //invocation target exception happens here

 

 

 





I must not be doing this right because I get an InvocationTargetException with the cause listed as DISP_E_MEMBERNOTFOUND.  This is an interesting error, because I get DISP_E_UNKNOWN_NAME if I enter in something else for the first invocation argument (i.e. "getDocument").  So this makes me think that it is the correct name but that I am calling it in the wrong way.  Can someone please shed some light on this for me?  Thanks!

 

Lyndsey

Serge Piletsky TeamDev Ltd. 1,066 posts since
Apr 24, 2006
Currently Being Moderated
1. Dec 23, 2009 5:37 PM in response to: Lyndsey
Re: Clear a cookie using OleContainer Automation

Hi Lyndsey,

 

In your sample you tried to invoke method "Document", but according to specification of WebBrowser object http://msdn.microsoft.com/en-us/library/aa752085%28VS.85%29.aspx the "Document" is the property. Therefore in order to get this property you need to use the property getter, for example:

Variant documentVariant = webBrowserAutomation.getProperty("Document");
IDispatch document = documentVariant.getPdispVal();

Please note that you can get this property only after navigation to a specified URL is complete, otherwise you it will return an NULL object.

 

There is the appropriate functionality for clearing cookies available in our JExplorer product and it's much easier to use, because it provides the convenient Java API for it and it does not require COM knowaladge.

 

-Serge

More Like This

  • Retrieving data ...