RE: Can I hit a web page in my Java application ??

I want to hit some web page through Java application, how should I do? Can I call something like HTTP://.... in my Java application??
TIA
Xin

Just compile and run the testVisit program as follows:
java testVisit http://www.yahoo.com
testVisit.java
==========
import java.net.*;
import java.io.*;
public class testVisit {
   public static void main(String[] args) {
      try {
         URL url = new URL(args[0]);
         URLConnection connection = url.openConnection();
         connection.setRequestProperty("Referer", args[0]);
         connection.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0");
         BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
         String Line;
         while ((Line = in.readLine()) != null) System.out.println(Line);
         in.close();
      } catch (Throwable e) {e.printStackTrace();}
};o)
V.V.

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());
    }

  • Rendering a web page in a java application?

    is it possible to show a web page based on tags from a java application .
    For example, in VB i believe there is a component that allows you to render html and view it as seen in a web browser
    I believe i have seen this done before.
    stev

    use JEditorPane

  • How can I launch a web browser from my Java application?

    I've reed about this at Question of the Week (http://developer.java.sun.com/developer/qow/archive/15/index.html). It doesn't work for me. I'm running win2000 and trying:
    try {
    Runtime.getRuntime().exec("start iexplore http://java.sun.com");
    } catch (Exception e) {
    System.out.println( e.getMessage() );
    I get:
    CreateProcess: start iexplore http://java.sun.com error=2
    What's wrong?

    This function will launch the default browser under Windows.
    public static void displayURL(String url) throws IOException   {
        String cmd = null;
        Process p;
        try  {
            String os = System.getProperty("os.name");     
            if (os != null && os.startsWith("Windows")) {
                if (os.startsWith("Windows 9") || os.startsWith("Windows Me"))  // Windows 9x/Me
                    cmd = "start " + url;
                else // Windows NT/2000/XP
                    cmd = "cmd /c start " + url;
                p = Runtime.getRuntime().exec(cmd);     
        catch(IOException x)        {
            // couldn't exec browser
            System.err.println("Could not invoke browser, command=" + cmd);

  • Can not open any web page in Safari

    can not open any web page in Safari on the IPad.  All other wireless features work fine.

    If this does not work then try a reset ,
    Reset your iPad by pressing the 'Sleep' and 'Home' button at the same time for about 15 seconds or so. Your iPad  will then go through a reset / reboot procedure and will be ready for use within about a minute.
    Don't worry about doing this as you will not lose data or settings.
    Good luck and do report back.

  • Can't export a web page

    I've just upgradded to iLife '08. When I try to save a web page the same as I had with the previous version of iPhoto, it doesn't work. The following steps are taken:
    Highlight eight photos in a folder
    Select File>Export
    In the Export Photos window, select Web Page tab
    Make other selections on the page and click Export
    Then I've tried various file destination folders and the Desktop
    When I click OK, an Exporting sub-window appears for a moment, then it changes to say
    Unable to generate web page and only gives me the option to Cancel
    It gives me no clues as to why it is unable to generate a web page. It has created the folders for the Images, Pages and Thumbnails but there isn't anything in those folders. I believe this is the same steps I used many times with iPhoto '06 to create a web pages.
    Does anyone have an idea on how to save web pages with the new iPhoto? How can I revert back to the old version of iPhoto?
    Thank you for you help.
    Bill H

    Bill:
    Welcome to the Apple Discussions. Try the following:download and run BatChmod on the iPhoto Library folder with the settings shown here, putting your administrator login name, long or short, in the owner and group sections. You can either type in the path to the folder or just drag the folder into that field. See if this will help.
    Next, log into another account or boot into Safe Mode and see if you can export to a web page. If so then there's something amiss with your account. If not, then a reinstall of iPhoto seems appropriate.
    Do you Twango?
    TIP: For insurance against the iPhoto database corruption that many users have experienced I recommend making a backup copy of the Library6.iPhoto database file and keep it current. If problems crop up where iPhoto suddenly can't see any photos or thinks there are no photos in the library, replacing the working Library6.iPhoto file with the backup will often get the library back. By keeping it current I mean backup after each import and/or any serious editing or work on books, slideshows, calendars, cards, etc. That insures that if a problem pops up and you do need to replace the database file, you'll retain all those efforts. It doesn't take long to make the backup and it's good insurance.
    I've written an Automator workflow application (requires Tiger), iPhoto dB File Backup, that will copy the selected Library6.iPhoto file from your iPhoto Library folder to the Pictures folder, replacing any previous version of it. It's compatible with iPhoto 08 libraries. iPhoto does not have to be closed to run the application, just idle. You can download it at Toad's Cellar. Be sure to read the Read Me pdf file.

  • 1. How can we search the Forum to see if a question has already been asked? 2. Can I send a Web Page and not just its Link?

    1. How can we search the Forum to see if a question has already been asked? Search goes back to Help and out of the Forum.
    2. Can I send a Web Page and not just its Link? Explorer allows it.

    1. How can we search the Forum to see if a question has already been asked? Search goes back to Help and out of the Forum.
    2. Can I send a Web Page and not just its Link? Explorer allows it.

  • How can I print a web page to a hard copy with Adobe?

    How can I print a web page to a hard copy with Adobe? When I print this particular page in the usual way it prints only the text of that page, not the photo that's also part of that page.

    I have Adobe SendNow, but I can buy another Adobe product if it will solve my web page printing problem.

  • I can't print any web page. after the print command, it wants to save xps files. on cannon printer. vista system

    can't print any web page. after the print command, it wants to save as a xps file.
    == This happened ==
    Every time Firefox opened
    == after up grade to 3.6.6 ==
    == User Agent ==
    Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 1.1.4322; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C)

    I found that Firefox/XPS had deleted all printer driver setups except for the XPS connection. I had to reinstall my printer connection in order to have that selection present in the printer dialogue box.

  • Since the last 3 upgrades (thru Firefox 7.0) I can't print a web page. This is true using 2 different printers. I have an iMac 10.6.8.

    Since the last 3 upgrades (thru Firefox 7.0) I can't print a web page. This is true using 2 different printers. I have an iMac 10.6.8.

    Just read that the default memory storage on FF is set to 5 mbs. You can up that by clicking on tools, advanced and overriding the default and set it to 50 mbs (if you use lots of tabs) or 10 mbs (if you use just a few).
    I open a blank tab and clear the cache periodically, while I am working. I can have several tabs open and watch videos on Youtube, by doing this. Have you cleared your cache?
    Since I have an older computer, I've also used CCleaner for years. I use it often, but always before signing off. You can get it free...search for CCleaner, download from Pirifoam free. I didn't change any of the settings and it clears crap left behind from uninstalling programs, clears all browsers at once of: cookies, history, passwords, etc. I love it!
    I had freezing, before using the "open blank tab, clear the cache" thing. Now I have no problems. Plus, as I said...you can change the default memory usage for FF and that should help too.
    Hope this helps! Good luck! :)

  • Following the upgrade to 34.0.5, I can no longer access web pages of our SAN, airco, vSphere Web Clients, etc. How can I correct this?

    Following upgrade to 34.05, can no longer access web pages of the SAN management interface, the airco system, the vSphere Web Client, etc. All still work in Chrome.
    The airco system gives an error:
    Firefox cannot guarantee the safety of your data on 10.32.16.50 because it uses SSLv3, a broken security protocol.
    Advanced info: ssl_error_no_cypher_overlap
    The SAN management interface and vSphere Web Clients display an empty page. Not sure whether these also have problems due to SSLv3.
    I understand you wanting to be cautious, but I seriously doubt I need to face an attack from our SAN. Please, at least give us an option to connect regardless.

    hello, ssl 3.0 is disabled in firefox versions 34 & upwards by default - if you want to re-enable it you can do that like this which will make you vulnerable to the recently published poodle attack though:
    enter '''about:config''' into the firefox address bar (confirm the info message in case it shows up) & search for the preference named '''security.tls.version.min'''. double-click it, change its value to '''0''' and restart the browser.
    https://blog.mozilla.org/security/2014/10/14/the-poodle-attack-and-the-end-of-ssl-3-0/

  • Haveing problems with Safari. It gives me an error message. Safari can't open the web page, because it can't establish a secure connection to the server. It only seams to have a problem on https sites. Any help would be apreciated.

    Safari keeps giving  and error message. " Safari can't open the web page( insert web page here) , because it can't establish a secure connetion to the server.
    It only seams to have a problem with https sites.
    Any help would be appreciated

    The "s" in "https" indicates the site is a secure server--usually a site that will require a password.  Connections to secure servers can be blocked by parental controls.  Are you using any parental controls, either through OSX's settings (in System Preferences) or third party parental control software (such as Netnanny)?  If so, check the settings to make sure they will allow the connection.

  • How can I "expire" a web page (prevent BACK button access)

    How can I "expire" a web page ?
    I know some sites will display the following message if we click on the
    BACK button in your browser.
    Warning: Page has Expired The page you requested was created using
    information you submitted in a form. This page is no longer available. As a
    security precaution, Internet Explorer does not automatically resubmit your
    information for you.
    To resubmit your information and view this Web page, click the Refresh
    button.
    How do I implement this feature??

    U want to disable back button click
    if yes i think
    javascript:window.history.forward(1);

  • Can't access teaming web page

    Hi, I've installed teaming 2.1 on a sles11 x64 virtual machine. I've used sun java jdk 1.6.21. After install I start the teaming server but then can't access the web page (I've used port 8080 in the URL). I used default network settings. I believe the mysql database has been created correctly. I think the problem is with Tomcat/java. I've included the output of tail --f catalina.out
    /opt/novell/teaming/apache-tomcat-6.0.18/bin/catalina.sh: line 309: /usr/jre/bin/java: No such file or directory
    Error occurred during initialization of VM
    Could not reserve enough space for object heap
    Could not create the Java virtual machine.
    Error occurred during initialization of VM
    Could not reserve enough space for object heap
    Could not create the Java virtual machine.
    Error occurred during initialization of VM
    Could not reserve enough space for object heap
    Could not create the Java virtual machine.
    the path shown in the first line of this output is not what I specified for java during the installation of teaming (I used /usr/java/jdk1.6.0_21). Any help would be greatly appreciated
    Lou

    Hi Lou,
    Have you set an environment var for the JAVA_HOME?
    you can set it system wide, create or edit /etc/profile.local, and add:
    export JAVA_HOME=/usr/java/jdk1.6.0_21
    Then reboot the system so the env var gets set globally.
    If the site is still not accessible, rerun the Teaming install choosing to reconfigure, double check the JAVA_HOME path set and see if that does the trick.
    Cheers,
    Willem

  • Adobe keeps crashing, you can be on a web page reading and the browser opens the page in a new browser. I did not have this problem the older versions. What can I do to fix this problem.

    adobe keeps crashing, you can be on a web page reading and the browser opens the page in a new browser. I did not have this problem the older versions. What can I do to fix this problem.

    See [[Firefox keeps opening many tabs or windows]]

Maybe you are looking for