Help about opening a PHP page from a Java application

Hi,
I would have some elements to open a PHP page from a little Java application I'm doing. I would like to know the classes I had to use, how to implement them, ...
In fact, I dial into my application my login, my password, and when I click on by "Connect" button, I must show the PHP page corresponding ti my profile onto the database. Picking up information from the database is not a problem, I know how to use SQL Packages in Java. The problem is to open a new page (IE or Netscape) when clicking on the "Connect" button in my application.
Thanks a lot for advice me.
C�dric

Hi
This class is from JavaWorld Tip 66 and I've used it to open web pages and files in a browser.
import java.io.IOException;
import java.util.*;
* A simple, static class to display a URL in the system browser.
* Under Unix, the system browser is hard-coded to be 'netscape'.
* Netscape must be in your PATH for this to work.  This has been
* tested with the following platforms: AIX, HP-UX and Solaris.
* Under Windows, this will bring up the default browser under windows,
* usually either Netscape or Microsoft IE.  The default browser is
* determined by the OS.  This has been tested under Windows 95/98/NT.
* Examples:
BrowserControl.displayURL("http://www.javaworld.com")
BrowserControl.displayURL("file://c:\\docs\\index.html")
BrowserContorl.displayURL("file:///user/joe/index.html");
* Note - you must include the url type -- either "http://" or
* "file://".
public class BrowserControl
     * Display a file in the system browser.  If you want to display a
     * file, you must include the absolute path name.
     * @param url the file's url (the url must start with either "http://"
or
     * "file://").
    public static void displayURL(String url) throws Exception
        boolean windows = isWindowsPlatform();
        String cmd = null;
        try
            if (windows)
                // cmd = 'rundll32 url.dll,FileProtocolHandler http://...'
                cmd = WIN_PATH + " " + WIN_FLAG + " " + url;
                Process p = Runtime.getRuntime().exec(cmd);
            else
                // Under Unix, Netscape has to be running for the "-remote"
                // command to work.  So, we try sending the command and
                // check for an exit value.  If the exit command is 0,
                // it worked, otherwise we need to start the browser.
                // cmd = 'netscape -remote openURL(http://www.javaworld.com)'
                cmd = UNIX_PATH + " " + UNIX_FLAG + "(" + url + ")";
                Process p = Runtime.getRuntime().exec(cmd);
                try
                    // wait for exit code -- if it's 0, command worked,
                    // otherwise we need to start the browser up.
                    int exitCode = p.waitFor();
                    if (exitCode != 0)
                        // Command failed, start up the browser
                        // cmd = 'netscape http://www.javaworld.com'
                        cmd = UNIX_PATH + " "  + url;
                        p = Runtime.getRuntime().exec(cmd);
                catch(InterruptedException x)
                    System.err.println("Error bringing up browser, cmd='" +
                                       cmd + "'");
                    System.err.println("Caught: " + x);
                    throw x;
        catch(IOException x)
            // couldn't exec browser
            System.err.println("Could not invoke browser, command=" + cmd);
            System.err.println("Caught: " + x);
            throw x;
     * Try to determine whether this application is running under Windows
     * or some other platform by examing the "os.name" property.
     * @return true if this application is running under a Windows OS
    public static boolean isWindowsPlatform()
        String os = System.getProperty("os.name");
        if ( os != null && os.startsWith(WIN_ID))
            return true;
        else
            return false;
     * Simple example.
    public static void main(String[] args)
      try
//        displayURL("file://c:\\Manual\\Amphibian Accounting Help Test 3.pdf");
//        displayURL("http://www.pro7.co.za");
        Properties prop = System.getProperties();
//        Enumeration enum = prop.propertyNames();
        Enumeration enum = prop.keys();
        while(enum.hasMoreElements())
          enum.nextElement();
      catch(Exception e)
    // Used to identify the windows platform.
    private static final String WIN_ID = "Windows";
    // The default system browser under windows.
    private static final String WIN_PATH = "rundll32";
    // The flag to display a url.
    private static final String WIN_FLAG = "url.dll,FileProtocolHandler";
    // The default browser under unix.
    private static final String UNIX_PATH = "netscape";
    // The flag to display a url.
    private static final String UNIX_FLAG = "-remote openURL";
}If you find a better solution please let me know!
Regards
Michael Williams

Similar Messages

  • How do i Hyperlink to a web page from a java application?

    How do i Hyperlink to a web page from a java application using internet explorer as my default web browser?

    It's very simple.You can start any Application with the class Runtime. The command is an array consisting of the path of .exe and the file to be open.
    String [] cmd={path of IE+Filename.exe,"URL of your website"}
    try
    Runtime.getRuntime().exec(cmd);
    catch (Exception e)
    System.err.println(e.toString());
    }

  • When i click in itunes for help its open me a page from words

    when open itunes in my computer and i click help my iphone or help its open me a page to my words from microsoft and i can not read the help i have a computer with windows 7 and its all working untill now i dont know what to do
    thanks for help

    Is there a music store in your country?
    Look across the top of the page.  it will say "Music"  "Movies" "TV Shows" etc if they are available

  • Open a word document from a Java Application

    Hi,
    Can I open a word document from a java GUI apllication and point to a bokkmark automatically in the word document when opened.

    See this thread:
    http://forum.java.sun.com/thread.jspa?threadID=228332&messageID=810684

  • Calling a PHP page from within Java

    We have an application that uses a lot of PHP (both web and cmd line based PHP calls) to manage the solution. One of the PHP pages in particular has two parameters that it takes to identify a city and a site within that city. The URL looks like this:
    http://host/directory/page.php?city=somecity&sitecode=1234&log=Y
    This page then logs in to the DB for that city and finds certain records for that site code and deletes them and creates a log file.There is a scheduled job that sends an email every night to a group (of which I am a member) with a listing of sites that contain these records that need to be deleted. Then someone (now me) opens a web browser and modifies the URL using the email and processes each one, one at a time.
    So, short term I have written an html form with a little javascript to give me a couple of fields, one for city and one for site.
    I then read those fields and call a js window.open() and open another page with the correct data. This way I can sit there and type them all in one after another then go back through each page and see the results later. This is a llot quicker as some of the pages can run for minutes finding and deleting the records. This page is provided by a third party so we can't modify it.
    Long term I would like to have a java app that finds all of these records and eliminates the records one at a time. So the class might look like this:
    Public class DeleteRecords() {
    String phpResult = null;
    String phpPage = null;
    Loop Through All DBS {
    // Some SQL that finds the records in this DB
    // The phpResult variable should be the php/html content that makes up the page after the process completes
    phpResult = http://host/directory/page.php?city=somecity&sitecode=1234&log=Y
    if(phpResult.contains("_Successful")){
                   // log successful event for city, site, and path to log file
    else {
              // log failed event for city, site, and path to log file }
    } // End DB loop
    } // End ClassIs this possible and are their samples somewhere on java.sun.com?
    Thanks,
    Shawn

    ShawnTaylor wrote:
    cotton.m wrote:
    HttpURLConnection is what you are looking for for starters. Code samples and explanations can be found in the tutorial here [_http://java.sun.com/docs/books/tutorial/networking/urls/index.html_|http://java.sun.com/docs/books/tutorial/networking/urls/index.html]
    There has to be an easier way though... like JDBC or something?If only that were true... The problem is the application is third-party, so we can't really 'touch' any of the tools being provided. My plan is to identify the orphaned records via JDBC but I need to use the tool provided for the clean up.
    Well then the first part of my post is your answer.

  • Help on accessing tables of SAP from the Java Application

    Hi All
    I want to access some tables available in SAP through my Java program.  Do I have to write any code for database connectivity or straightaway I can write SQL statements in my Java code?
    Can anyone please suggest the sample code for this?
    Thanks in Advance,
    Vijay.

    the above one is with out connection pool, check this with connection pool.
    import com.sap.mw.jco.*;
    public class JcoTest {
    private static JCO.Client theConnection;
    private static IRepository theRepository;
        private static final String POOL_NAME = "myPool";
    public static void main(String[] args) {
        JCO.Pool connPool = JCO.getClientPoolManager().getPool(POOL_NAME);
        if (connPool == null) {
          JCO.addClientPool(POOL_NAME,
                            5,      //number of connections in the pool
                            "client",
                            "username",
                            "paswword",
                            "EN",
                            "hostname",
                            "00");
            theConnection = JCO.getClient(POOL_NAME);
      retrieveRepository(); 
      try {
      JCO.Function function = getFunction("RFC_READ_TABLE");
      JCO.ParameterList listParams = function.getImportParameterList();
      listParams.setValue("BSAUTHORS", "QUERY_TABLE");
      theConnection.execute(function);
      JCO.Table tableList = function.getTableParameterList().getTable("DATA");
      if (tableList.getNumRows() > 0) {
       do {
        for (JCO.FieldIterator fI = tableList.fields();
          fI.hasMoreElements();)
          JCO.Field tabField = fI.nextField();
          System.out.println(tabField.getName()
               + ":t" +
               tabField.getString());
         System.out.println("n");
       while (tableList.nextRow() == true);
      catch (Exception ex) {
       ex.printStackTrace();
      JCO.releaseClient(theConnection);
    private static void retrieveRepository() {
      try {
       theRepository = new JCO.Repository("saprep", theConnection);
      catch (Exception ex)
       System.out.println("failed to retrieve repository");
      public static JCO.Function getFunction(String name) {
        try {
             return theRepository.getFunctionTemplate(name.toUpperCase()).getFunction();
        catch (Exception ex) {
         ex.printStackTrace();
          return null;
    Regards
    vijay

  • How to open a JSP page from a form ??? plz help

    hi ..
    i want to know how to open a jsp page from a oracle apps form using a button .
    the requirement is that whenever we click on the button created on the form, it opens a jsp page.
    plz help me ..its urgent !! :-(

    In portlet project, to navigate between pages, you should not use the URL property to link to a page. Instead, portlets use navigation via action handling. You use the Page Navigation editor to set up links to pages; that is, the navigation editor sets the action property.
    Here is an example to hyperlink ans button to open a new page:
    # From within the IDE, create a new portlet project. This action creates the project and one page, PortletPage1.jsp.
    # Create a second portlet page, called PortletPage2.jsp, for the project.
    # Drop a Hyperlink component onto the first portlet page, PortletPage1. (You can drop the Hyperlink on the page in the Design window or on the PortletPage1 node in the Outline window.) Change the Hyperlink's text property to Next Page.
    # Drop a Button component (found in the Basic section of the Palette) onto the second portlet page, PortletPage2.
    # Open the Page Navigation Editor. It displays the two pages (PortletPage1.jsp and PortletPage2.jsp) of the application.
    # Click the PortletPage1.jsp icon in the Navigation window to expand it, and then drag a connector from hyperlink1 to PortletPage2.jsp. Change the name of the connector from case1 to Page2.
    # Click the PortletPage2.jsp icon in the Navigation window to expand it, and then drag a connector from button1 to PortletPage1.jsp. Change the name of the connector from case1 to Page1.
    # Run and deploy the portlet. The browser displays PortletPage1 and you should see the Next Page hyperlink. When you click the Next Page hyperlink, the Apache Pluto Portal server displays PortletPage2. Click the Page2 button to return to PortletPage1.
    Sherry
    Creator Team

  • After upgrading to FF 3.6.12 I can no longer view PHP pages from my hard drive.

    After upgrading to version 3.6.12 I can no longer open PHP web pages from my hard drive. When I create or edit web pages I view them from my hard drive first before uploading, as many webmasters do to look for errors before taking them live.
    I can view PHP pages online, but from my hard drive it just spawns endless empty tabs. Instead of just opening the page it asked me what to open it with, thinking the PHP web page is a script.
    It was working fine before the upgrade. I had a page open that I wanted to edit, which it reopened when my browser restarted.
    Then I edited the page. All I did was add a link to it. Then I hit the refresh button to see the change and instead of reloading the page, FF asked me what to do with the PHP script, prompting me to save it or choose what program to open it with.
    I selected to view it with FF and it just spawned endless tabs. They wouldn't stop. Had to shut down FF and it probably had 40 tabs opened with nothing on them. I tried other PHP pages from my hard drive that opened fine before, but it did the same thing with them.
    I tried finding help online and I see others have had the same problem, but no solution was offered that worked. I tried rebooting, same story, it wants to know what to do with the PHP script.
    I'm being forced to use another browser, so I'm going to go download Chrome now. If this probably isn't fixed soon I'll simply give up on FF. It's not worth the aggravation. I can't tell you how much TIME I've wasted today -- HOURS.
    Very disappointed.

    Thanks for the reply. It doesn't have to process the php, it just has to show the HTML content. It did that just fine before the last upgrade but won't now.
    I've seen that page you referenced: http://kb.mozillazine.org/File_types_and_download_actions.
    It doesn't help. The things it says to look for aren't there for me, specifically:
    browser.download.pluginOverrideTypes
    plugin.disable_full_page_plugin_for_types
    I followed the rest of the instructions but it didn't help.
    I did get it to quit opening tabs, instead it prompts me what it should do with the file every time now. What it should do, and used to do, is open the php page and display the HTML content.
    Any other ideas?

  • Opening an ADF page from an OA framework page

    Hello,
    We have an OA framework page (a custom app) deployed in Oracle 9i Application server. We intend to develop some ADF pages which will be deployed in a separate Oracle 10g AS. I would like to know if it is possible to open an ADF page from an OA page and the basic interoperability between them. If someone can throw some light on the feasibility of this approach, it would really be helpful. Are there any material available on this?
    Please let me know your thoughts on this. Thanks in advance
    Raja

    You way want to ask this on the OA Forum as well.
    Because you are running the apps on different servers the interoperability can only be through the db layer. I'm not aware of a solution where the apps are running in the same context, meaning you can't have an transaction spanning both apps.
    To open a page of an other app is simply done by putting a link in one app which points to the second app.
    Timo

  • Open an OAF page from a link in e-mail

    Hi
    How to open an OAF page from an e-mail where its link is passed through the Notification. How to open the page directly from this link. How to overcome with this issue as we are not able to open as some function security might be there. Is there any workaround for this. Please help me to overcome from this.
    Thanks.
    Regards,
    Chandra.

    Search through the old threads. this issue has been discussed earlier.
    --Shiv                                                                                                                                                                               

  • Opening a HTML page from a Navigation link

    Hi All,
           I have a requirement of adding a new link at the navigation bar of WebClient. This link will open a static html page with some contents. I have created the page required for it. But I don't know how the link will be created at Navigation bar and how to open the html page from it. I am using the SAP CRM 5.0 and I want to add the link at Default profile.
      Please help.
    Thanks
    Indranil Datta

    Hi Sujit,
        Thanks for your help. I have created a new navigation bar entity and added that in a customized profile. I have also mentioned the page name and path for that link from tran SPRO. I found that link after logging into IC WebClient. But that link is not connected with the required page. If I click on the link page, it get refreshed but without any change.
    Thanks,
    Indranil Datta.

  • When I open Safari 5.1.5, it automatically opens all the pages from my previous session. Can I turn off that feature , and how?

    When I open Safari 5.1.5, it automatically opens all the pages from my previous session. Can I turn off that feature , and how?

    Hi...
    Open System Preferences > General
    Deselect:  Restore windows when quitting and re-opening apps
    Restart your Mac.

  • Opening a WEB page from FORMS CS & WebForms

    Hi,
    We would like to open a Web Page from a forms running in
    client/server as well as from a form runningover the web.
    Over the web, we plan to use SHOW_DOWUMENT (Even tough it seems
    broken, on forms 6.0, the only way we have got it working was by
    using the parameter that overwrites the current page (the form),
    we cannot have it open an URL in another window)
    In C/S mode, the SHOW DOCUMENT does not work. What is the proper
    way to lauch an URL in a browser in C/S mode ?
    Is there a way to determine if we're running in CS mode or Web
    Mode ? We would like to use the same code both on the web and in
    C/S
    Example pseudo code:
    if (Running in CS Mode) then
    open the URL using C/S method
    else
    open the URL with show dowument
    fi
    Thanks
    null

    use '_blank' as parameter, not '_self'.
    Guy Dallaire (guest) wrote:
    : Hi,
    : We would like to open a Web Page from a forms running in
    : client/server as well as from a form runningover the web.
    : Over the web, we plan to use SHOW_DOWUMENT (Even tough it
    seems
    : broken, on forms 6.0, the only way we have got it working was
    by
    : using the parameter that overwrites the current page (the
    form),
    : we cannot have it open an URL in another window)
    : In C/S mode, the SHOW DOCUMENT does not work. What is the
    proper
    : way to lauch an URL in a browser in C/S mode ?
    : Is there a way to determine if we're running in CS mode or Web
    : Mode ? We would like to use the same code both on the web and
    in
    : C/S
    : Example pseudo code:
    : if (Running in CS Mode) then
    : open the URL using C/S method
    : else
    : open the URL with show dowument
    : fi
    : Thanks
    null

  • Open a web page from Oracle

    plz, i use oracle 10g but how can i open/ping a web URL from pl/sql code?

    Thank you venky but you should post the link as link and not between tags !
    [Re: Opening a web page from oracle
    SS                                                                                                                                                                                                                                                                                                                                               

  • Is the way to retrieve the deleted pages from the database application

    Hi,
    I was just deleted the pages from my database application wizard. Now, i want to retrieve the deleted pages, can you help me to retrieve those pages.
    Thankyou.

    Halloween can be a scary time -- especially if you Oops your APEX application. Of course you can't travel back in time but through the miracle of flashback, you may be able to get the APEX appl. back to where it was when. I tried these approaches and was successful with them.
    *** This assumes flashback is running on the APEX schema(?). Your abiliy to go back a given number of minutes (or hours?) will depend on whether the saved values still exist in the database. ***
    A) If you modify a page and want to go back to what you had, say, about 30 minutes ago.
    1) Under the Utilities button (on that page), select History.
    2) Determine how far back in time you want to go by examining the list of editing changes displayed.
    3) Do a page export of that page (also under Utilities) and fill in “As of __ minutes ago”.
    4) If you don’t want to lose what you've got on the “damaged” page, copy it to another page number for now.
    5) Import the exported page file.
    6) Check if you got back what you wanted.
    7) If not, try an earlier (or later) time and have another go at it.
    B) If you deleted the wrong page in the application!
    1) Assuming the last thing you did was this deletion, export the entire application filling in “As of __ minutes ago”.
    2) Just to be careful, import the file to a different unused application number. Don't overwrite someone else's application.
    3) Copy the deleted page from the new application back to where you need it.
    4) Clean up by deleting the unneeded application.
    C) If, "Doh," you deleted the wrong application!!!!
    1) Are you able to retire? If no, then proceed!
    2) Create a minimal application (with a single page) with the same number as the one deleted.
    3) Export the application filling in “As of __ minutes ago” with an appropriate number of minutes.
    4) The export file should contain the code you need to restore.
    5) You can inspect it with an editor.
    Look about line 25 for" Pages: <number>".
    For specific pages look for "page_000nn".
    5) Import the file to the same appl. number. You should get everything back!
    YMMV: Your mileage may vary!
    I'll take my leave with the words of that immortal song:
    "Yes. Oops, Oops, Oopsie! Good Bye. But Oops, Oops, Oopsie. Don't Cry."
    (With apologies to Ted Fio Rito, 1900-1971.)
    Howard

Maybe you are looking for

  • Missing progess indication at bottom right of screen

    I used to get a progress indicator at the bottom right of screen particularly when downloading something. It gave an indication of how the process in question was going. It isn't there anymore. I think it disappeared when I downloaded the last Firefo

  • SQL Injection with Oracle Text

    I did a search here for any posts about SQL Injection on Oracle Text indexes, but returned no hits. Can anyone give their opinion about whether SQL Injection is a concern when using Oracle Text or what steps can be taken ahead of time to prevent (or

  • The missing library problem.

    I understand that there's already a lot of threads about the sudden disappearance of iTunes libraries, however I'm typing this up because I'd like to point out in a bit more detail what I'm seeing happening to my computer, and maybe have a collective

  • How to retrieve information from iCloud (earlier than the 3 most recent backups) ?

    I had to restore my iPod 4th generation to factory settings and I'm trying to get all the information back from iCloud backup. The thing is that I had waited about a week or two(instead of right away) to try to put the information back into the iPod.

  • Poweshell command to pull the CNames out of list of Host name.

    Hi shiva, Please try below commands and let me know Get All the records: Get-DnsServerResourceRecord -ZoneName abc.com -ComputerName server001 Get all the records of specific type (A, AAAA, CNAME) Get-DnsServerResourceRecord -ZoneName abc.com -Comput