Connecting to website using URLConnection

I can use the following type of code to connect to a ftp site, but I get a timeout when using an http site. What shoudl I be doing? thanks
Paul
String urlName="http://www.sun.com/index.html";
URL url = new URL(urlName);
URLConnection connection = url.openConnection();
connection.connect();
//then I use this to read the file
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));

The only time it fails is in windows 7 and the address used of HTTP://servername. I updated the above post to show it works in XP with ff12.
There is no proxy server involved.
I am logged into the domain.
If I use the fully qualified servername as the address it works. Http://servername.domain.local

Similar Messages

  • I am unable to connect to websites using Firefox. I can connect to websites with Internet Explorer. Please advsie.

    I am unable to connect to websites using Firefox. I can connect to websites with Internet Explorer.
    Please advise.
    Thank you.

    see http://kb.mozillazine.org/Firewalls

  • Not able to connect to website using Wizard, please help!

    Hello All,
    I've been trying to connect to an existing website using the Connection Wizard, but I keep getting the "Your Secure FTP (SFTP) username or password is incorrect. Please check your connection information." I am able to connect to the site using WinSCP so I know my information is correct, and I sure I'm entering the data correct so I have no idea what the problem is. I do have a @ as one of my characters of my password, maybe Contribute has an issue with special chars in the password. Does anyone know if this is true or what the resolution maybe?
    Any help would be greatly appreciated.
    Thanks,
    -L
     

    When I have received that error, it was because the FTP user account permissions were too restrictive for Contribute.  At least with standard FTP, the user accounts needed to have access to all folders within our website.  Once that was changed, they were able to connect using the wizard.
    I hope that helps.
    Kathy

  • When connecting to website using sso, packet sniffing shows ntlm user is using {server name}\{user name} instead of {domain name}\{user name}

    I moved to windows 7 and firefox 12 and my internal website via the servername (not FQN) is now prompting me for the username and password in firefox. I do not get prompted for a username and password when using IE9 to access the site via servername (not FQN).
    packet sniffing shows IE9 is using my windows domain as the windows domain. packet sniffing shows Firefox is using the web servers servername as the domain.
    If I use the fully qualified server name then firefox authenticates successfully. this is not a problem on my winxp workstation with firefox 12.

    The only time it fails is in windows 7 and the address used of HTTP://servername. I updated the above post to show it works in XP with ff12.
    There is no proxy server involved.
    I am logged into the domain.
    If I use the fully qualified servername as the address it works. Http://servername.domain.local

  • SAP Connection with a Website using HTTPS

    SAP Gurus,
    We are on SAP 4.7.  Requesting you to revert whether it is possible to connect SAP 4.7 with HTTPS (Secured) thru some BAPI or BADI.
    Details:
    1. The Business Process expected to be set is for Vendor Transactions.
    2. That is, the Vendor liability document is expected to be posted from the data that would flow thru Internet HTTPS.
    3. The request would originate from a website (that is NOT SAP).
    4. It would have the Vendor Party credentials.
    5. The Line Item Data would come to SAP thru HTTPS and it is expected that SAP would accept the request and process it.
    6. After successful process of the file, the system would generate Accounting Document.
    7. This Accounting Document is expected to be sent back to the originator website, using the same HTTPS connection.
    8. The entire leg is expected to be completed in 180 seconds.
    Qs:
    a. Is it possible to achieve this with using some BAPI or BADI?
    b. Whether it is possible to connect to SAP with some RFC (RFC may not be the right technical word, please recommend what else) using the Secured connection, that is HTTPS?
    Many Thanks

    Hi,
    Thanks for ur reply.
    I am facing the following problem.(I am using Https protocol)
    1.A runtime exception is thrown at line no 5. This is the main problem i am facing and as i am not able to establish the connection with the server, i was able to proceeed further.
    2. I need help for setting the content type(Remember i am using Https)
    3. As u said at server side file has to be decompressed but that is not under my scope so it is not a problem for me.
    4. once connection is established, I need to create a byte stream and write to destination and then i have to check the response sent by the server.
    I am looking for an idea how to establish the connection with the server. any references let me know.
    Code written by me:
    URL url = new URL("https://www.sun.com");
    URLConnection conn = url.openConnection();
    conn.setRequestProperty("content-type","Application/x-zip-compressed"); // I dont think this is correct way of setting the header var
    conn.connect(); // an exception is raised here
    conn.setDoOutput(true);
    OutputStream ostream = conn.getOutputStream();
    Message was edited by:
    vbr3650

  • I AM UNABLE TO CONNECT TO ANY WEBSITE USING FIREFOX. EVEN THOUGH, I HAVE BEEN USING FIREFOX ON THE SAME COMPUTER FOR YEARS WITH NO DIFFICULTY. THE PROBLEM AROSE AFTER COMCAST, MY ISP, RECOVERED FROM A WIDESPREAD OUTAGE THAT LASTED 5 HOURS.

    I SUCCEEDED IN TRANSFERING ALL MY BOOKMARKS TO GOOGLE CHROME. THIS WILL ALLOW ME ACCESS TO WEBSITES WHILE I WAIT FOR A METHOD TO REPAIR MY FIREFOX PROGRAM. IN A PREVIOUS MESSAGE, I EXPLAINED THAT I WAS UNABLE TO ACCESS ANY WEBSITE USING FIREFOX AFTER COMCAST, MY ISP, RECOVERED FROM AN OUTAGE THAT LASTED 5 HOURS. WHENEVER I TRIED TO CONNECT TO A SITE, A POP-UP MESSAGE APPEARED INDICATING: "UNABLE TO INITIALIZE THE APPLICATION'S SECURITY COMPONENT. THE MOST LIKELY CAUSE IS PROBLEMS WITH FILES IN YOUR APPLICATION'S PROFILE DIRECTORY. CHECK THAT THIS DIRECTORY HAS NO READ/WRITE RESTRICTIONS." I EVEN REMOVED FIREFOX FROM MY COMPUTER AND DOWNLOADED IT AGAIN, FIGURING THAT BY NOT MERELY USING AN UPGRADE, I WOULD BE INSTALLING A COMPLETELY FRESH DOWNLOAD. UNFORTUNATELY, I RECEIVED THE SAME DISAPPOINTING RESULT, WITH THE SAME POP-UP MESSAGE RE-APPEARING. HOWEVER USING BOTH GOOGLE CHROME AND INTERNET EXPLORER, I WAS ABLE TO CONNECT TO WEBSITES. SO I HAVE TO CONCLUDE THAT THE PROBLEM IS NOT WITH MY INTERNET CONNECTION.

    Press '''START + R''' in keyboard to open the '''Run''' box(or '''start''' then '''run''') , type in the RUN box '''%APPDATA%''' (or copied in just i wrote, bold text) then click '''OK'''. A Windows Explorer window will appear, in this window, choose '''Mozilla''' then '''Firefox''' then '''Profiles'''. Each folder in the "Profiles" folder (e.g., "xxxxxxxx.default") is a profile on your computer (maybe is one file if you have only one profile).
    see for more info : [http://kb.mozillazine.org/Profile_folder_-_Firefox Profile folder - Firefox ]
    try it, good luck
    thanks again

  • How to connect to website through computer if i do not use internet through phon's sim

    how to connect to website through computer if i do not use internet through phon's sim

    Connect through wifi.
    Turn off Cellular data through settings __ General __ Network __ Cellular Data on/off

  • Since the IOS 5 update my iPad seems to run a lot slower connecting to websites and general use? Can anyone help?

    Since the IOS 5 update my iPad seems to run a lot slower connecting to websites and general use? Can anyone help?

    Digging a little deeper on here, and I've Cleared the Safari cache, and rebooted , so i'll see if it is any better!!!!!

  • Dreamweaver sudenly stopped connecting to website, fine one day then cannot connect the next. I can connect using CUTEFTP any suggestions what has stopped dreamweaver from connecting?

    Dreamweaver suddenly stopped connecting to website, fine one day then cannot connect the next. I can connect using CUTE FTP any suggestions what has stopped Dreamweaver from connecting?

    Have you tried clearing DW's program cache yet? That's usually my first step if something "just started happening"...
    Deleting a corrupted cache file
    Server updates can cause DW to need a setting change. Have you already tried toggling Use Passive FTP in your site settings yet?
    Has anything changed on your local network, like an update to a firewall?
    If you are connected via wireless router, a low likelihood but possible thing to test would be a wireless router problem. Try connecting the computer directly to your modem, bypassing the wireless router (if you aren't using an all in one modem/router setup) to see if that makes any difference.

  • FireFox message of my bank website using 5 years: you can tell Firefox to start trusting this site's identification. Even if you trust the site, this error could mean that someone is tampering with your connection. Don't add an exception

    FireFox message of my bank website using 5 years: you
    can tell Firefox to start trusting this site's identification.
    Even if you trust the site, this error could mean that someone is
    tampering with your connection. Don't add an exception

    send me email

  • Unable to connect to website losing connection and the result is displayed as Secure Connection Failed (Error code: ssl_error_access_denied_alert)

    Secure Connection Failed
    An error occurred during a connection to website name
    Peer received a valid certificate, but access was denied.
    (Error code: ssl_error_access_denied_alert)
    # The page you are trying to view can not be shown because the authenticity of the received data could not be verified.
    # Please contact the web site owners to inform them of this problem. Alternatively, use the command found in the help menu to report this broken site.

    Still experiencing this problem and hoping someone may have some ideas to try on the server.

  • I get error messages when I try to visit certain websites using Mozilla Firefox but not when I use other browsers

    About two days ago I noticed that when I tried to access certain websites using Firefox I always got this error message; "The connection was reset". I initially thought it was a problem with my isp before noticing that the network was fine on my phone and iPad. I then attempted opening the same links that brought up the error message on the TorBrowser and it worked perfectly.
    Basically the only website that works on my Firefox browser right now is Google but if I do a search on Google and then click on any link that comes up as a result I get the same error message, "The connection was reset". I can also log into my gmail account but I cannot access any other website including Feedly, Tumblr, Twitter, Yahoo, Wordpress, Blogspot, even though they work fine on my other browser.
    I cleared my cache and cookies, wiped out all the browsing history but the problem persisted so I uninstalled Mozilla Firefox and reinstalled it. The problem is still there. I checked the proxy settings, I went through all the solutions on this page https://support.mozilla.org/en-US/kb/firefox-cant-load-websites-other-browsers-can?esab=a&as=aaq and still nothing. I am not sure what the problem is here but any solution will be much appreciated. I have used Firefox for years now and I am not really comfortable using another browser.
    I use a Macbook OS X Version 10.9.4 and the latest Firefox 32.0.1

    Create a new profile as a test to check if your current profile is causing the problems. <br>
    See '''Creating a profile''':
    *https://support.mozilla.org/kb/profile-manager-create-and-remove-firefox-profiles
    *http://kb.mozillazine.org/Standard_diagnostic_-_Firefox#Profile_issues
    If the new profile works then you can transfer files from a previously used profile to the new profile, but be cautious not to copy corrupted files to avoid carrying over the problem <br>
    '''Profile Backup and Restore'''
    *http://kb.mozillazine.org/Profile_backup
    *https://support.mozilla.org/en-US/kb/back-and-restore-information-firefox-profiles
    *http://kb.mozillazine.org/Transferring_data_to_a_new_profile_-_Firefox

  • I used to manage 3 websites using both my imac and macbook, using dropbox, however I can no longer access them from my mac book.

    I have been managing 3 websites using iWeb for the last several years, using both my iMac and Macbook.  However for the last two weeks, I can no longer access these sites from my macbook.  It appears "empty".  When I first started seeing this, I took it to the Genius Bar in another city and he moved some library contents to my desktop - still didin't help.
    I know iWeb is a thing of the past, but I can't stop right now and learn something new for about the next 4 weeks (in a sports team in the middle of a season)
    .  After that, I will have time to learn a new product.
    Also, what is a suggestion for replacing iWeb?  Sandvox? Rapid Weaver?
    Thanks!

    What do you mean when you say you "can no longer access these sites?" Does that mean you can't connect to those sites in your web browser, or that they aren't showing up in iWeb?
    If the latter, note that your iWeb data is all entirely stored in a hidden file. In the Finder, choose Go -> Go To Folder and paste the following path into the window that opens:
    ~/Library/Application Support/iWeb
    In that folder, you will find a single file, called Domain. That's got all the data for all your iWeb sites. If that file is missing, or if it has become corrupt, you will need to restore it from an earlier backup.
    As for replacing iWeb, either Sandvox or RapidWeaver should work. Which works best will depend on your own tastes. Note that neither is capable of fully importing iWeb sites, as those sites will have a lot of content that is copyrighted by Apple. For more information about transitioning to one of these products, see:
    http://rapidweaverfaq.org/site/migrating_from_iWeb.html
    http://www.karelia.com/sandvox/help/z/Transitioning_from_iWeb.html

  • HT201318 Hello. I have just built a website using iWeb but cannot upload it. I curently have the 25gb account. There doesn't appear to be any facility here for the net. ASm I correct in thinking I need an upgrade, or am I doing something wrong?  Thanks

    Hello. I have just built a website using iWeb but cannot upload it. I curently have the 25gb account. There doesn't appear to be any facility here for the net. Am I correct in thinking I need an upgrade, or am I doing something wrong?  Thanks

    iCloud does not provide website hosting. You will need to find another website hosting service - there are many to choose from - and upload your site there. How you do this depends on what version of iWeb you have.
    In order to upload your existing site in iWeb '09 and above:
    Click on the name of the site in the sidebar: the publishing settings pane will open. Set 'Publish to' to 'FTP'. Enter the name of the site and a contact address (if desired).
    In the 'FTP Server Settings' section you will need to know the server address (your hosting service can tell you that), and your username and password for that service. Your site will be published in a folder with its name at root level of the server, with an index.html file at root level (which will overwrite any index.html file which may be there already). The 'Directory/Path' field may need to include a path such as '/webspace/' or 'ht_docs/' - this is dependent on your hosting service and they should tell you this. If you want to publish within a folder you can add that to the path.
    You can then click the 'Test connection' button so that iWeb can check that it can get access to your server space. You should enter the URL of the site in the 'URL' field so that rss feeds and internal links have the correct address.
    To publish using an earlier version of iWeb:
    From the File menu choose 'Publish to a folder'. You should create a folder somewhere convenient specifically for this and choose it when publishing to a folder: this folder should not contain anything else.
    You now need an FTP program (FTP is the 'protocol' used for uploading) to upload the contents of the folder to your server.Cyberduck is free (donation requested): Transmit is $34 but I think better. You will need the server address (your hosting service can tell you that), and your username and password for that service. You can drag the contents of your folder to your webspace, or create a folder there and drag the contents to that if you prefer.
    Some facilities that iWeb provided when hosted on MobileMe will not work on other servers: comments on weblogs and photos, password-protecting your site (some hosts may provide this), searching in the weblog, and a hits counter (again, some hosts can provide code for this). Slideshows in iWeb will work on other hosts than MobileMe (they use different code when FTPing which doesn't depend on scripts hosted on MobileMe as the MobileMe version does); however there is an issue with the 'buttons' which control the slideshow which are images hosted on me.com - these depend on images which used to be hosted on MobileMe. The poster 'Old Toad' on the Apple Forums has provided a workaround, described at http://oldtoadstutorials.net/No.26.html.

  • How can I use URLConnection to use applet communication with servlet?

    I want to send a String to a servlet in applet.I now use URLConnection to communicat between applet and servlet.
    ====================the applet code below=========================
    import java.io.*;
    import java.applet.Applet;
    import java.awt.*;
    import java.net.*;
    //I have tested that in applet get data from servlet is OK!
    //Still I will change to test in applet post data to a servlet.
    public class TestDataStreamApplet extends Applet
    String response;
    String baseurl;
    double percentUsed;
    String total;
    public void init()
    try
    java.net.URL url = new java.net.URL(getDocumentBase(),"/servlet/dataStreamEcho");
    //String currenturl=new String("http://lib.nju.edu.cn");
    java.net.URLConnection con = url.openConnection();
    //URL currentPage=getCodeBase();
    // String protocol=currentPage.getProtocol();
    // String host=currentPage.getHost();
    //int port=currentPage.getPort();
    // String urlSuffix="/servlet/dataStreamEcho";
    // URL url=new URL(protocol,host,port,urlSuffix);
    // URLConnection con=url.openConnection();
    con.setUseCaches(false);
    con.setDoOutput(true);
    con.setDoInput(true);
    ByteArrayOutputStream byteout = new ByteArrayOutputStream();
    PrintWriter out=new PrintWriter(byteout,true);
    String currenturl=new String("http://lib.nju.edu.cn");
    String var1=this.encodedValue(currenturl); //encode the data
    String data="currenturl="+var1;
    out.print(data);
    out.flush();
    con.setRequestProperty("Content-Length",String.valueOf(byteout.size()));
    con.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
    byteout.writeTo(con.getOutputStream());
    BufferedReader in=new BufferedReader(new InputStreamReader(con.getInputStream()));
    String line;
    while((line=in.readLine())!=null)
         System.out.println(line);
    catch (Exception e)
    e.printStackTrace();
    private String encodedValue(String rawValue)
         return(URLEncoder.encode(rawValue));
    =========================The servlet code below=====================
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    public class DataStreamEcho extends HttpServlet
    {public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
          res.setContentType("text/plain");
          PrintWriter out = res.getWriter();
          Runtime rt = Runtime.getRuntime();
          out.println(rt.freeMemory());
          out.println(rt.totalMemory());
          response.setContentType("text/html; charset=GBK");     
          request.setCharacterEncoding("GBK");
          PrintWriter out = response.getWriter();
          HttpSession session=request.getSession();
          ServletContext application=this.getServletContext();
          String currenturl=(String)session.getAttribute("currenturl");
          out.print(currenturl);
    =============================================================
    I have done up,but I found the program don't run as I have thought.
    Can you help me to find where is wrong?Very thank!

    You are trying to pass the current URL to the servlet
    from the applet, right?
    Well, what I put was correct. Your servlet code is
    trying to read some information from session data.
    request.getInputStream() is not the IP address of
    anything...see
    http://java.sun.com/products/servlet/2.2/javadoc/javax
    servlet/ServletRequest.html#getInputStream()
    Please read
    http://www.j-nine.com/pubs/applet2servlet/Applet2Servle
    .htmlNo,you all don't understand I.
    I want to send an Object to the server from a applet on a client.not url only.I maybe want to send a JPEG file instead.
    All I want is how to communicate with a servlet from an applet,send message to servlet from client's applet.
    for example,Now I have a method get the desktop picture of my client .and I want to send it to a server with a servlet to done it.How can I write the applet and servlet program?
    Now my program is down,But can only do string,can't not done Object yet.Can anyone help me?
    =======================applet=============================
    public void init()
    try
    java.net.URL url = new java.net.URL(getDocumentBase(),"/servlet/dataStreamEcho");
    //String currenturl=new String("http://lib.nju.edu.cn");
    java.net.URLConnection con = url.openConnection();
    //URL currentPage=getCodeBase();
    // String protocol=currentPage.getProtocol();
    // String host=currentPage.getHost();
    //int port=currentPage.getPort();
    // String urlSuffix="/servlet/dataStreamEcho";
    // URL url=new URL(protocol,host,port,urlSuffix);
    // URLConnection con=url.openConnection();
    con.setUseCaches(false);
    con.setDoOutput(true);
    con.setDoInput(true);
    ByteArrayOutputStream byteout = new ByteArrayOutputStream();
    PrintWriter out=new PrintWriter(byteout,true);
    String currenturl=new String("http://lib.nju.edu.cn");
    String var1=this.encodedValue(currenturl); //encode the data
    String data="currenturl="+var1;
    out.print(data);
    out.flush();
    con.setRequestProperty("Content-Length",String.valueOf(byteout.size()));
    con.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
    byteout.writeTo(con.getOutputStream());
    con.connect();
    BufferedReader in=new BufferedReader(new InputStreamReader(con.getInputStream()));
    String line;
    while((line=in.readLine())!=null)
         System.out.println(line);
    catch (Exception e)
    e.printStackTrace();
    =======================servlet=============================
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
         response.setContentType("text/html; charset=GBK");
    //request.setCharacterEncoding("GBK");
    PrintWriter out = response.getWriter();
    HttpSession session=request.getSession();
    ServletContext application=this.getServletContext();
    //String currenturl=(String)session.getAttribute("currenturl");
    String currenturl=(String)request.getParameter("currenturl");
    out.print(currenturl);
    File fileName=new File("c:\\noname.txt");
    fileName.createNewFile();
    FileOutputStream f=new FileOutputStream(fileName); //I just write the String data get from
    //applet to a file for a test.
    byte[] b=currenturl.getBytes();
    f.write(b);
    f.close();
    }

Maybe you are looking for

  • Error 0x80070035 only on one of 20 remote machines, after months of use... strange!

    I have been using a Windows 7 Server on my network for Quickbook for 2 years without a hitch.  Since the weekend I started getting error code 0x80070035 'network path was not found' for the server only.  I can see the server on my mapped network, I c

  • Custom search in the Customer Interaction Center

    I have a somewhat unique custom requirement in CIC. The user wants to go to our custom Alta Vista search upon pressing enter when either the name or phone number field is populated. We have a search that is activated only when the CSEARCH_SEARCH butt

  • Report for Material PO Text in purchase requisition

    Hi Team,     In Purchase requisition user maintains specifications in Material PO Text in item details-TEXT tab. User wants a report which can pull this text against a PR Item No.   Anybody knowa a way to do this Rajesh

  • Drag and drop into iTunes

    I used to be able to drag and drop a mp3 file from mail directly to iTunes. Not anymore. How can i save these music files to iTunes now? When I use the Lion save feature it takes so many more clicks and I'm not sure how to set up the folders so that

  • Newbie: Should I Use PersonalJava?

    Hey Guys: GOAL: Get a simple app running on an IPAQ, that eventually connects to a backend database. PROBLEM: Which VM and technology to use. DETAIL: After about a week of exploring J2ME for the 1st time, I thought having PersonalJava on the IPAQ was