Test for URL exist and redirect if not

Hi people,
Ive never done any java programming in the past, so i've done a few tutorials and a lot of google searching, but I dont know where to start and would really appreciate someone either pointing me in the right direction, or actually putting the code in their post that I can copy and paste please. I dont even know if its possible.
What I need to do is check a URL on a local webserver to see if the website exists, or is running and if it is then goto that local url. If it doesnt then to redirect to another local webserver and url.
Something along the lines of
Check url servername/path/logon.aspx
if that exists the go to servername/path/logon.aspx
if it doesnt exist go to servername2/path/logon.aspx
Really appreciate your help

This should do what you want..
String[] urlPaths = {"Non working path", "http://www.sun.com", "Another path"};
URL url = null;
for(int i = 0; i < urlPaths.length; i++) {
     try {
          System.out.println("yay1");
          url = new URL(urlPaths);
          System.out.println("yay2");
          InputStream is = url.openStream();
          System.out.println("yay3");
          break;//Stops the forloop
     } catch(Exception e) {
          //If you get an exception you can be rather certain that you don't have a
          //connection established.
EDIT: A bit to slow..
Edited by: prigas on Nov 25, 2008 6:41 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Similar Messages

  • Test for System File and Delete System File

    I have about 300 different tests that I run using TestStand, each with a somewhat unique report output filename:
      Example:  0-RMC 80 Timer_Interface_MaxValue_Report.html
    The filename includes the
        Number of Errors
        Product Name
        Build Revision
          and a unique test name.
    I would like to add a step to an existing initialization routine to test for an existing report file name and if it exists, bypass the test sequence.
    The question is, how do I run a system command within TestStand to test for a file, for example:
      If (SystemCommand(dir Locals.ReportPath\0-RMC 80 Timer_Interface_MaxValue*.html) then
        Don't run this test...
    Similarly, I also need to know how to delete a file from within TestStand.
        SystemCommand(Del 9999*.*)
    Mike

    You can use the FindFile method in the TS API:
    FindFile Method
    Syntax
    Engine.FindFile ( fileToFind, absolutePath, userCancelled, promptOption = FindFile_PromptHonorUserPreference, srchListOption = FindFile_AddDirToSrchList_Ask, isCommand = False, [currentSequenceFile])
    The function itself returns a boolean which indicates if the file exists or not. 
    Then just use a Call Executable step to run command line string to delete the file.
    Hope this helps!
    jigg
    CTA, CLA
    teststandhelp.com
    ~Will work for kudos and/or BBQ~

  • [svn:osmf:] 13640: First checkin of unit tests for FLV tags and their parser

    Revision: 13640
    Revision: 13640
    Author:   [email protected]
    Date:     2010-01-19 15:07:11 -0800 (Tue, 19 Jan 2010)
    Log Message:
    First checkin of unit tests for FLV tags and their parser
    Modified Paths:
        osmf/trunk/framework/OSMFTest/org/osmf/OSMFTests.as
    Added Paths:
        osmf/trunk/framework/OSMFTest/org/osmf/net/httpstreaming/flv/
        osmf/trunk/framework/OSMFTest/org/osmf/net/httpstreaming/flv/FLVTestHelper.as
        osmf/trunk/framework/OSMFTest/org/osmf/net/httpstreaming/flv/TestFLVHeader.as
        osmf/trunk/framework/OSMFTest/org/osmf/net/httpstreaming/flv/TestFLVTagAudio.as
    Property Changed:
        osmf/trunk/framework/OSMFTest/org/osmf/

    Thanks for posting this!
    I would only mention that your definition is incomplete for this -
    Contextual selector A type of Style Sheet Selector that
    and that it's most often referred to now as a Descendent selector, not a contextual selector.  It's basically the same as the Compound selector that you have already defined....

  • My friend's iPod touch 5th gen is locked somehow for 41 years and she does not have a backup. Is there a way to unlock the iPod without restoring it or loosing the pictures and videos from the camera roll?

    My friend's iPod touch 5th gen is locked somehow for 41 years  and she does not have a backup. Is there a way to unlock the iPod without restoring it or loosing the pictures and videos from the camera roll, the applications can be redownloaded and she had no music. Is there any known bug about ipods locking on their own because no one seemed to have tried to bypass the 4 digit code and it is locked for 26 million minutes.So thank you if anyone has any information or help for us.

    Your friend may have placed the ipod next to an object that repeatedly pressed the screen.  Under certain circumstances this can lead to what appears to the iTouch to be failed attempts to access the system.  After repeated failed attempts, the Touch increases the waiting time required for the password and may ultimately lock in the way you describe.
    It's been a while since this was posted, but this might be informative to someone else who finds themself in a similar predicament.

  • Why does my Airport Express say "self assigned IP address"?  No IP address for the ethernet, and it is not connecting to my cable router any longer...

    Why does my Airport Express say "self assigned IP address"?  No IP address for the ethernet, and it is not connecting to my cable router any longer...

    Some cable providers.....like mine, a well known company......seem to take anywhere from a few moments to sometimes up to 30 minutes to allow their equipment back at the cable company to fully reset and issue a new fresh connection.
    So, it would not hurt to leave things powered down for 15-20 minutes or more when you perform the reset that John Galt suggests.

  • I cannot shut dow my MacBook Pro using the apple icon (as it was suppose to be), actually I have to press and hold the on/off buttom. I have taken twice for Mac dealer and they did not solve the problem. What must I do?

    I cannot shut dow my MacBook Pro using the apple icon (as it was suppose to be), actually I have to press and hold the on/off buttom. I have taken twice for Mac dealer and they did not solve the problem. What must I do? I would to remark that I have installed 2 antivirus and uninstalled one of them. Since then I have facing this troublesome issue. Thanks

    Uninstall the other AV software. They are not needed. All they do is cause trouble like you are having now.
    If you have been forcing the Mac to shut down with the power switch you may nave corrupted your disk. You should repair it with disk Utilty to remove any corruption the shutdwons may have cased.
    Allan

  • I bought a used i pod 4 for my daughter and it does not have the message icon on it: how can i put the icon on the i pod and get it receive and send messages

    I bought a used i pod 4 for my daughter and it does not have the message icon on it ( not even in settings) how can I get the message icon on it so it can receive and send messages

    Try:
    - Reset the iOS device. Nothing will be lost
    Reset iOS device: Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.
    - Reset all settings
    Go to Settings > General > Reset and tap Reset All Settings.
    All your preferences and settings are reset. Information (such as contacts and calendars) and media (such as songs and videos) aren’t affected.
    - Restore from backup. See:       
    iOS: How to back up
    - Restore to factory settings/new iOS device.
    -  Make an appointment at the Genius Bar of an Apple store.
    Apple Retail Store - Genius Bar

  • HT4623 i am trying to update my Ipad 1 but it tells me i have no updates available under my general settings. i talked to someone on the phone yesterday and they said my software version is 2 updates behind.  i paid for some aps and they will not open wit

    i am trying to update my Ipad 1 but it tells me i have no updates available under my general settings. i talked to someone on the phone yesterday and they said my software version is 2 updates behind.  i paid for some aps and they will not open with my cu

    You are as far as you can be with the original iPad; only iPad 2 and greater will update to 7+

  • I have just updated the i06 software for my ipad and it will not connect to my home wifi network - all my other devices are able to connect - i have tried all troubleshooting options and none have worked - please help

    I have just updated the i06 software for my iPad and it will not connect to my home wifi network - all my other devices are able to connect to my wifi network.
    I have attempted all troubleshooting actions suggested and nothing has worked. I have restored my iPad network and factory settings - Please help - this is frustrating me

    you have to set up your router to solve th problem. first find and write down the ipad mac address.
    then log on to your router using your laptop or any device that can connect to router at 192.168.0.1 in your web browser. please check out my posting about how to resolve the wifi connection problem.
    i think the ios6 update has reset the networking but if you set up the router then you should not have the same problem any more.

  • MultiMedia Center for Think Offerings for Windows XP and 2000 -- will not install on Windows 7

    MultiMedia Center for Think Offerings for Windows XP and 2000 -- will not install on Windows 7  in compatibility mode or any other way. I receive error " can not open \device\memory" and then " This program can not run on his hardware.
    Thinkcenter E series 8291-ETU --- upgraded from XP to Windows 7 yesterday.
    Any ideas on how to get this product installed in Windows 7 ?

    I recently did a clean install of Win7 Ult on my X61 7676A24, and this is the only Lenovo software that I could not find a Win 7 solution for. However,
    1. I was able to load WinDVD8 upgrade (from Lenovo's Win7 information page) after first loading the WinDVD5 version that was the last good release for Vista.
    2. The Multimedia Center for Think Offerings is basically Roxio's suite for writing cd/dvd's, drag to disc and so on.
    Since I could not load this anyway, I was forced to try out Win7's inbuilt cd/dvd writing - it works perfectly well.  Even better, Win7 natively supports an excellent ISO burning tool. So, I think if you explore these inbuilt tools, you can probably live without the Mul Cent for Think Off.
    TP600E > T41 > X61 > X201T > X220 i7 IPS 8GB 160GB SSD

  • I need help my iphone 5c has been on charge for 5 hours and still has not turned on past the charging symbol, what can i do? (baring in mind i got this phone 2 days ago brand new.)

    i need help my iphone 5c has been on charge for 5 hours and still has not turned on past the charging symbol, what can i do? (baring in mind i got this phone 2 days ago brand new.)

    Do you see a lightning bolt near the battery , Battery is charging (supposedly(  IF  not return to where  you purchased it  (also make sure that the charger is on)  if still not charging with lighting bolt bring it back

  • I made a purchase of books through the program, with the money as I was cleared for two purchases and I did not have books

    I made a purchase of books through the program, with the money as I was cleared for two purchases and I did not have books

    This morning, I did a power down and reboot of the I-Pad, that got the "Please Wait" resolved.  I then tried clicking on the additional picture set and it did download and install, so the problem is now resolved.

  • HT4914 I was billed for iTunes Match and I was not aware and would like to cancel it and get a refund for it. I don't store my music in iCloud and still have 4.5 gig of my 5 gig free. Please advise

    I was billed for iTunes Match and I was not aware and would like to cancel it and get a refund for it. I don't store my music in iCloud and still have 4.5 gig of my 5 gig free. Please advise

    Go here:
    http://www.apple.com/support/itunes/contact/
    and follow the instructions to contact the iTunes Store and make your request.
    Regards.

  • How do i get a password?  I changed my password last night and it doesn't work.  Or, it is asking for a password for something else and I do not know which one!

    how do i get a password?  I changed my password last night and it doesn't work.  Or, it is asking for a password for something else and I do not know which one!

    Usually when someone mentions "passowrd" in a posting it will not be related to an Adobe product but to the machine that you are trying to implement some installation or update for.  If you explain more about what you are trying to do and describe what you encounter it might be easier to determine what you are dealing with... include a screenshot to help explain as well if you can.

  • I have had my macbook pro for 3 days, and it will not charge.  I tried several differnt outlets, tried cleaning and wiggling the magnet charger, still nothing.  Has this happened to anyone else? Any suggestions?

    Has this happened to anyone else?

    Jaybunni wrote:
    I have had my macbook pro for 3 days, and it will not charge.
    You have 14 days from the date of purchase to return your MBP.  Personally, I would not waste my time "troubleshooting" if the normal solutions do not work.
    Return the MBP for one that works before your 14 days are up and/or call AppleCare ASAP!!!
    Good luck!

Maybe you are looking for

  • Error "Jurisdiction code could not be determined" in so create bapi

    I am using the bapi "SO_NEW_DOCUMENT_ATT_SEND_API1" for creating the sales order, it gives the error "Jurisdiction code could not be determined" Sometimes there are two juridiction code maintained in the system . 1) During the ship to party address c

  • Error Message in version 7.1.0.33

    Greetings, My desktop software automatically upgraded to version 7.1.0.33, but I'm getting the same error message that I was getting in version 7.0.0. I was hoping that the upgrade would fix the error. Shane. Z10 STL100-3 (version 10.3.1.2708) LTE Pl

  • Document line with price zero in SBO 2007 A

    Hi All We have a DI API AddOn that occationally has to create a document line with the total price of zero. In SBO 2005 A we just set SBODocument.Lines.Price = 0, but that doesn't work in SBO 2007 A. In 2007A when we set SBODocument.Lines.Price = 0 i

  • Java Studio Creator IDE Download Error

    So I just watched a demo on the Java Studio Creator IDE and thought I'd go ahead and download it. So I followed the link from within the demo. I then had to create an account. That went just fine. After I got logged in, I went to the following url: h

  • Can't start Adobe Premiere Elements 13 video editor.

    It says: "Adobe Premiere Elements 13 has stopped working" without additional details. It doesn't close, it is not frozen, but it does not work. I tried Adobe Premiere Elements 12 (trial version) which had no problem at all on my PC. I'm using the 64