Can not get session in the IE browser run via ActiveX [message #405829] |
Tue, 06 January 2004 10:29 |
Eclipse User |
|
|
|
Originally posted by: alexma919.hotmail.com
hi, there:
In my project, I open a browser window via ActiveX and the browser will
open a webpage(written by jsp). The webpage will create a session
variable. In this page, there is a hyperlink to another jsp page (open a
new IE window like that <a href="another.jsp" target=_blank>another
page</a>). In the new page, the session variable will be got from session,
but fail to got it. The session variable is null. How can I got the
variable? The www server I use is BEA Weblogic 7.0. The browser is IE6.0.
Thanks for your answer.
|
|
|
Re: Can not get session in the IE browser run via ActiveX [message #405840 is a reply to message #405829] |
Tue, 06 January 2004 14:45 |
Veronika Irvine Messages: 1272 Registered: July 2009 |
Senior Member |
|
|
1) you need to open the new window in the same process
2) you need to register this new browser as a top level browser
See below for an example of how this is done. See also bug report 29396 for
a more detailed discussion.
import org.eclipse.swt.*;
import org.eclipse.swt.internal.ole.win32.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.ole.win32.*;
import org.eclipse.swt.widgets.*;
public class PR29396 {
static final int NewWindow2 = 0x000000fb;
static final int RegisterAsBrowser = 0x228;
public static void main(String[] args) {
final Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
OleFrame frame = new OleFrame(shell, SWT.NONE);
OleControlSite site = new OleControlSite(frame, SWT.NONE,
"Shell.Explorer");
site.doVerb(OLE.OLEIVERB_INPLACEACTIVATE);
// create automation object
OleAutomation iwebbrowser = new OleAutomation(site);
// register the new window as a top-level browser for target name
resolution
iwebbrowser.setProperty(RegisterAsBrowser, new Variant(true));
// navigate to URL
int[] rgdispid = iwebbrowser.getIDsOfNames(new String[]{"Navigate2",
"URL"});
int dispIdMember = rgdispid[0];
Variant[] rgvarg = new Variant[1];
int[] rgdispidNamedArgs = new int[1];
rgdispidNamedArgs[0] = rgdispid[1];
String url = "http://your_url/index.jsp";
rgvarg[0] = new Variant(url);
iwebbrowser.invoke(dispIdMember, rgvarg, rgdispidNamedArgs);
rgvarg[0].dispose();
// free automation object
iwebbrowser.dispose();
// add listener in case this window opens a new window
final OleListener[] listener = new OleListener[1];
listener[0] = new OleListener() {
public void handleEvent(OleEvent event) {
Variant[] args = event.arguments;
switch (event.type) {
case NewWindow2: {
// Create a new window
Shell shell2 = new Shell(display);
shell2.setLayout(new FillLayout());
OleFrame frame2 = new OleFrame(shell2, SWT.NONE);
OleControlSite site2 = new OleControlSite(frame2, SWT.NONE,
"Shell.Explorer");
site2.doVerb(OLE.OLEIVERB_INPLACEACTIVATE);
// create automation object
OleAutomation iwebbrowser2 = new OleAutomation(site2);
// register the new window as a top-level browser for target name
resolution
iwebbrowser2.setProperty(RegisterAsBrowser, new Variant(true));
// Hack to get IDispatch address of embedded web browser
Variant temp = new Variant(iwebbrowser2);
IDispatch idispatch = temp.getDispatch();
idispatch.AddRef();
// Copy Idispatch address to ppDisp
Variant ppDisp = args[0];
int byref = ppDisp.getByRef();
COM.MoveMemory(byref, new int[] {idispatch.getAddress()}, 4);
// free automation object
iwebbrowser2.dispose();
// add listener in case this window also opens a new window
site2.addEventListener(NewWindow2, listener[0]);
shell2.open();
}
}
for (int i = 0; i < args.length; i++) {
args[i].dispose();
}
}
};
site.addEventListener(NewWindow2, listener[0]);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}
"alexma919" <alexma919@hotmail.com> wrote in message
news:bte2mb$50p$1@eclipse.org...
> hi, there:
>
> In my project, I open a browser window via ActiveX and the browser will
> open a webpage(written by jsp). The webpage will create a session
> variable. In this page, there is a hyperlink to another jsp page (open a
> new IE window like that <a href="another.jsp" target=_blank>another
> page</a>). In the new page, the session variable will be got from session,
> but fail to got it. The session variable is null. How can I got the
> variable? The www server I use is BEA Weblogic 7.0. The browser is IE6.0.
>
> Thanks for your answer.
>
|
|
|
|
Powered by
FUDForum. Page generated in 0.03409 seconds