Interenent Explorer from Java

Hello! I need to post data (for login data) using ie (internet explorer) and then to display the browser to user.
I use JACOB for browser control and here is the code:
package testJACOB;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import com.jacob.activeX.ActiveXComponent;
import com.jacob.com.Dispatch;
import com.jacob.com.SafeArray;
import com.jacob.com.Variant;
class IETest
public static void main(String[] args)
ActiveXComponent ie = new ActiveXComponent(
"clsid:0002DF01-0000-0000-C000-000000000046"); //IE
Object ieo = ie.getObject();
String path = "http://localhost:3333/portal/Login";
String postData = "userName=uuu&password=ppp";
String content = null;
try
content = URLEncoder.encode(postData, "UTF-8");
catch (UnsupportedEncodingException e)
e.printStackTrace();
SafeArray sa = new SafeArray(Variant.VariantByte, content.length());
sa.fromByteArray(content.getBytes());
Variant[] arg = new Variant[]{
new Variant(path),
new Variant(),
new Variant(),
new Variant(sa),
new Variant("Content-type: application/x-www-form-urlencoded") };
ie.invoke("Navigate2", arg);
Dispatch.put(ieo, "Visible", new Variant(true));
Browser sucsefully opens, but I get 'null' post data in my web-app. It seems that web-app got nothing in http-request for post data.
What is wrong in my code?
Thank you very much.
Vladimir.

WundahWheel,
learn first how to use interfaces of WebBrowser Control. Here is a simple example. Substitute in NJAWIN WebBrowser Example (file WebBrowserComponent.java)
public void DocumentComplete(
          Object srcObj,
          DispatchPtr pDisp,
          ObjectRef URL)
          throws COMException {
        System.out.println("DocumentComplete");
        if (doc == null && control != null) {
            doc = new MSHTML.IHTMLDocument2(control.getDocument());
            if (!doc.isNull())
                DispatchPtr disp = doc.getScript();
                IHTMLWindow2 win = new IHTMLWindow2(disp);
                win.showModalDialog("http://www.google.com");
                doc.addEventListener(
                    HTMLDocumentEvents2.class,
                    new DocumentListener());
            else {
                doc = null;
                return;
}While invoking "DocumentComplete" event you will see WebBrowser Dialog.

Similar Messages

  • Open Internet explorer from Java

    Hi everyone!
    Doew anybody know how to open IOnternet Explorer from Java.I have tried
    String browserCommand = ("\"C:\Program Files\InternetExplorer\iexplore.exe\"");
         URL theUrl=new URL("http://www.yahoo.com/"); // or whatever
         Runtime.getRuntime().exec(browserCommand+ " "+theURL);
    but something goes wrong with the escape characters I use.
    I would be greatful to receive any advice.
    Thanks in advance!

    or...
        private static boolean showInBrowser(String url){
             String os = System.getProperty("os.name").toLowerCase();
            Runtime rt = Runtime.getRuntime();
            try{
                 if (os.indexOf( "win" ) >= 0) {
                      // this doesn't support showing urls in the form of "page.html#nameLink"
                     rt.exec( "rundll32 url.dll,FileProtocolHandler " + url);
                 } else if (os.indexOf( "mac" ) >= 0) {
                     rt.exec( "open " + url);
                 } else if (os.indexOf( "nix") >=0 || os.indexOf( "nux") >=0) {
                      // Do a best guess on unix until we get a platform independent way
                      // Build a list of browsers to try, in this order.
                      String[] browsers = {"epiphany", "firefox", "mozilla", "konqueror",
                                "netscape","opera","links","lynx"};
                      // Build a command string which looks like "browser1 "url" || browser2 "url" ||..."
                      StringBuffer cmd = new StringBuffer();
                      for (int i=0; i<browsers.length; i++)
                           cmd.append( (i==0  ? "" : " || " ) + browsers[i] +" \"" + url + "\" ");
                      rt.exec(new String[] { "sh", "-c", cmd.toString() });
                 } else {
                      return false;
            }catch (IOException e){
                 return false;
            return true;
        }

  • Open an Explorer from Java

    How i can open the default explorer from Java and redirect it to an especific URL?

    here is a code snippet that might help.
       public StringBuffer getMainPage (String host, String port, boolean sendToBrowser)
          String       url  = "http://" + host + ":" + port;
          String       line = "";
          StringWriter sw   = new StringWriter();
          // send it.
          post(line, url, sw);
          try
             if ( sendToBrowser )
                // send the default browser to the proper page for this host
                String cmd = "rundll32 url.dll,FileProtocolHandler " + url;
                // System.out.println("cmd =" + cmd );
                Process p = Runtime.getRuntime().exec(cmd);
          catch ( Exception e )
             // e.printStackTrace();
          // System.out.println(" output ='" + sw.toString() + "'" );
          if (sw.toString().length() != 0)
             return sw.getBuffer();
          else
             return null;
       }

  • Lauching Internet Explorer from java program

    How can I lauch internet explorer from a java program. I need codes
    Thanks

    What? Is this the Question of the Day or something?
    http://forum.java.sun.com/thread.jsp?forum=31&thread=342624&tstart=0&trange=30

  • How to open Internet explorer from java

    how can one open internet explorer through java and also displays the desired webpage in it.

    p = r.exec(runie);Whenever you use exec on a Runtime object, you need to get an InputStream off the System.err output. If this InputStream is not absorbed in some way, then it can stop the process. The process may not reach its destined finish point. The Java Documentation does not inform you of this, though experience will give you some unanswered questions, such as 'Why does this process never reach the finish point'.
    James

  • Launching IE from Java

    Hi,
    My requirement is as follows:
    I must be able to launch Internet explorer from Java. Also i must be able to open a pdf file inside it (embedded inside IE i.e. acrobat reader inside IE).
    I have tried using OleControlSite object, but does not work ( i mean it does not launch IE). I have also tried using exec. Here, how do i open ? What are the parameters that need to be passed to exec? i have tried the following code.....
    String WIN_PATH = "rundll32";
    String WIN_FLAG = "url.dll,FileProtocolHandler";
    String cmd = WIN_PATH + " " + WIN_FLAG + " " + "c:\\NYSE Glossary.pdf";
    try {
    p = Runtime.getRuntime().exec(cmd);
    } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    This piece of code opens the pdf file in acrobat reader(stand-alone). But i want the file to be open inside IE(acrobat embedded inside IE).
    Can anyone suggest me a solution?
    Thanks and Regards,
    Kris

    i have done the same thing.. it just opens the pdfin
    acrobat reader.. not as part of IEThat has nothing to do with the code... you need to
    install Acrobat plugin in IE. :)Annie. Have you changed login?

  • How to connect to mysql from java app

    hi
    please say the procedure for connecting to mysql database from java app.
    .) what should i give in environmental variables
    .)where can i find the driver class for the mysql
    .) syntax of the url
    eg:- DM.getConnection("jdbc:mysql:..............what comes here..............");

    You can also get connections from a DataSource. Simple example:
                MysqlDataSource msds = new MysqlDataSource();
                msds.setUrl("jdbc:mysql://127.0.0.1:3306/dbdame");
                msds.setUser("user");
                msds.setPassword("pass");
                Connection c = msds.getConnection();Explore your options and be sure to consider connection pooling.

  • To Open a Brio Query from Java

    Hi,
    I am using Hyperian Intellegence Explorer to get a information from the Data Base.
    I want to do it automatic,because this we are doing this as a BAU.
    I want to reduce my work load ,so thatpln to write a Code.
    Please help me how to Open an existing BrioQuery from Java.

    corlettk wrote:
    http://geocities.com/khory_scythe/Praxeum/jedicode.html
    Yeah that fits... except I swear a lot. Is that allowed?
    Jedi use their powers to defend and protect, never to attack others.Can we throw an exception for this one?
    edit: actually i disagree with the whole jedi code, its wrong, wheres the fun...
    Mel

  • Failure when Upgrading from Java 1.2 to Java 1.3

    After upgrading from Java 1.2 to Java 1.3 I get an "Internal Server Error" when trying to run even the simplest jsp.
    Java 1.3 runs successfully in other cases such as compiling and running from the command prompt or from JDeveloper.
    I have the following configuration on my server:
    - Windows 2000
    - Oracle 8.1.7
    - Apache 1.3
    - Tomcat 3.2.3.
    I'm testing the jsp by using a client that has:
    - Windows 2000
    - Internet Explorer
    Any help would be appreciated.

    I get this even with the new 1.4 beta 2 - currently
    reverted back to original

  • Running .EXE file from Java

    Do you know, how run an .exe file, for example Internet Explorer or other program, from Java application?
    It's very important for me.

    Too run external program and pass string arguments see class java doc
    of java.lang.Runtime method exec . You see online or download or
    rename src.jar to s.zip EXTRACT and see
    exec
    public Process exec(String[] cmdarray,
    String[] envp)
    throws IOException
    Executes the specified command and arguments in a separate process with the
    specified environment.
    This is a convenience method. An invocation of the form exec(cmdarray, envp)
    behaves in exactly the same way as the invocation exec(cmdarray, envp,
    null).
    Parameters:
    cmdarray - array containing the command to call and its arguments.
    envp - array of strings, each element of which has environment variable
    settings in the format name=value, or null if the subprocess should inherit
    the environment of the current process.
    Returns:
    A new Process object for managing the subprocess
    Throws:
    SecurityException - If a security manager exists and its checkExec method
    doesn't allow creation of the subprocess
    IOException - If an I/O error occurs
    NullPointerException - If cmdarray is null, or one of the elements of
    cmdarray is null, or one of the elements of envp is null
    IndexOutOfBoundsException - If cmdarray is an empty array (has length 0)
    See Also:
    ProcessBuilder
    getRuntime
    public static Runtime getRuntime()
    Returns the runtime object associated with the current Java application.
    Most of the methods of class Runtime are instance methods and must be
    invoked with respect to the current runtime object.
    Returns:
    the Runtime object associated with the current Java application.

  • Invoking Acrobat PDF compare from Java code

    Need to invoke the Adobe Acrobat XI's PDF compare feature using Java code.
    Description:
    ========
    We are exploring the possibilities of passing 2 PDF's from Java to Adobe Acrobat XI SDK to get the compared results in new PDF.
    If anyone has explored with this feature... please share your thoughts.

    You would need to write a custom plugin to Acrobat that calls the compare APIs (as they are only accessible from C/C++).  Your plugin can then expose whatever from of IAC/IPC that it wishes to communicate with your Java code.
    Of course, this is all DESKTOP code since Acrobat can't be used on a server.

  • Opening HTML file from java GUI

    Can someone please tell me how I can open a HTML file in Internet Explorer from a Java GUI,
    I have an asssignment I am doing for college and I was toying with the idea of putting in helpfiles, for the program, can anyone tell me the easiest way of apcomplishing this???
    Thanks in advance for your help,
    Kaspah

    Although this should answer your question, there are other (cross platform) ways to do what you want. As opposed to your "must have internet explorer" solution. Swing has a built in html viewer you might use, for example. I've been doing some reading on java/xml solutions. I don't consider myself knowledgeable enough (yet) to comment on that solution though. A delimited text file would be another solution. Useing that solution you could treat the file like a set of parrallel arrays on the hard drive and disply your text on pre-formated labels. Anyway, here is a link to you answer......
    http://java.sun.com/products/jdk/1.2/docs/api/java/lang/Runtime.html#exec(java.lang.String)
    Ron_W

  • How to open a brio Query from Java

    Hi,
    I am working with Hyperion Intellegence Explorer to take care of the MIS related activities, to pull out the Data from the Data Base and Export it to the Excel
    Actually this is a BAU.
    So i want to reduce my work burdon. I am a Java Progrrammer too. So i want to automate all the thing from Java.
    Pls help me below to open a Brio files from Java,so that i can proceed to process the Query and export it on to the Excel.,

    Don't double post the same question. You can continue in your previous thread
    [http://forums.sun.com/thread.jspa?threadID=5367120]
    I'm locking this one and it will be removed it later.
    db

  • How to open a web browser from java

    Hi
    Would anybody please help me with this. I need to open a web browser from my java app but I don't know. What method I can use?
    Thanks.
    Hung.

    You can use the Runtime class for this. It can run any command. So, you can run the .exe file of your Web browser.
    The following code will run Internet Explorer (assuming iexplorer.exe is in C:\Program Files\Internet Explorer):
    import java.lang.Runtime;
    public class Explore{
    public static void main(String[] args) {
    try{
    Process p = Runtime.getRuntime().exec("C:\\Program Files\\Internet Explorer\\iexplore");
    }catch (Exception e) {
    System.out.println("Exception: " + e);

  • How to run Other application from Java

    I want to run other applications such as IE.exe, notepad.exe from Java? How can I run?

    Dear Friend, the following is the code to open IExplorer from Java Program
    class RunTimeTest {
    public static void main(String args[]) {
    try {
    Runtime.getRuntime().exec("C:\\Program Files\\Internet Explorer\\IEXPLORE.exe");
    catch(Exception e) {
    [\code]
    ALL THE BEST
    Shiva                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Maybe you are looking for

  • 24" iMac starts with a strange screen and freezes. HELP!

    My iMac froze and I restarted it. Now when I start it got weirdturquoise stuff on each side of the screen. It does show the apple logoand the loading thingy but after that they disappear it freezes againand nothing happens. Also tried booting from DV

  • Upgrading Language in CUE 8.6.1 on SME

    I urgently need to install a language pack onto my CUE 8.6.1. Its the SM-SRE-710-K9 deployment. I would prefer to keep my current version and simply add-on an additional Language (GB). Is this possible ?? When I try it - I can only upgrade using with

  • Photo App not opening (iPhone iOS 5)

    So, i updated my iPhone 4 to iOS 5, absouletely everything works. I then updated my mother's iPhone 4 to iOS 5, there the exact same phone (I just dont sync photos on the computer with my phone, with hers i do) However on her phone, when u click the

  • Photoshop CMYK different than online converters?

    Hi. I have a very weird problem here. When I try to convert RGB to CMYK in JavaScript code or existing online converters I always get the same and what I assume is the correct result. Example is: 69, 25, 209 > 67, 88, 0, 18 But when I do it in Photos

  • Invoices or Incoming payment appear several times

    Hello We see on some customers statement invoices with the same amount and same document number twice and incoming payments same amount, same doc num three times We sue SAP 2007 SP00 PL 39 What could be the issue because customer statement is obvious