SOS HttpURLConnection

Hi,
I'm Sebastiano and I'm a students ...
I'm developping a Server-Client application for Web and I have a big problem with Java Programming.
I need to make an istance of the HttpURLconnection class (belogging to java.net package and subclass of URLConnection), to use an URL connection for Http protocol.
In the "Java 2 Platform, Standard Edition, v 1.3.1
API Specification" about the URL cIass,and in particular about its method openConnection() to returns a URLConnection object that represents a connection to the remote object referred to by the URL, I have found this reference:
"If for the URL's protocol (such as HTTP or JAR), there exists a public, specialized URLConnection subclass belonging to one of the following packages or one of their subpackages: java.lang, java.io, java.util, java.net, the connection returned will be of that subclass. For example, for HTTP an HttpURLConnection will be returned"
So I used this statement to create an HttpURLConnection object:
HttpURLConnection urlCon = url.openConnection()
But when i try to compile my program the fooling error occurs:
"Error #: 354 : incompatible types; found: java.net.URLConnection, required: java.net.HttpURLConnection at line 81, column 62"
What can I do to use HttpURLConnenction class?
Thanks for your answers,
Sebastiano

It's called casting. You can only cast an object to a another class if it is compatible with that class. In this case, it would work.

Similar Messages

  • Every time I update LR to a new version I seem to need a patch to make it work..... once again here I am SOS! I've just update LR to the 5.7 version and It wont let me start it: The application was unable to start correctly (0xc000007b).

    Every time I update LR to a new version I seem to need a patch to make it work..... once again here I am SOS! I've just update LR to the 5.7 version and It wont let me start it: The application was unable to start correctly (0xc000007b).

    Your system is missing a couple DLLs that LR needs, but the fix at Adobe is to copy them to the LR folder which gets replaced for each install, so you have to redo it after each LR install.  It would be worth documenting the process and saving the DLLs so you don’t have to ask about it each time:
    http://helpx.adobe.com/lightroom/kb/error-unable-start-correctly-0xc00007b.html
    You might also use the AIO210 program to add them as detailed in this YouTube video—maybe this is a more permanent fix, but since the files are from media-fire be very careful about what you do so as not to install a virus on your computer. 
    I’d scan the downloaded ZIP you download with whatever virus and internet security software you have and don’t be fooled by extraneous popups you might see during the download process.  I was able to download the aio210.zip after authorizing one Captcha window and closed at least one bogus popup trying to get me to install other software.  I also scanned the downloaded zip with two virus scanners and both said it was clean.  Here is the YouTube video, where the link to the ZIP to download is in the description once you expand it:
    https://www.youtube.com/watch?v=vlT0N2CX50g

  • Stuck Threads on weblogic 10.3.2 Holding lock HttpURLConnection

    We are having issue with STUCK THREADS on weblogic 10.3.2. Basically my application makes a lot of web service calls over HTTPS and once in a while I see few STUCK THREADS and most of the time they clear but sometimes I have to bounce my server to clean.
    I have a thread dump, according to this its holding lock at weblogic.net.http.HttpURLConnection.getInputStream
    Any help to resolve this problem is highly appreciated.
    ThreadDump:
    <May 24, 2011 9:59:08 AM EDT> <Error> <WebLogicServer> <BEA-000337> <[STUCK] ExecuteThread: '11' for queue: 'weblogic.kernel.Default (self-tuning)' has been busy for "604" seconds working on the request "weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl@b607d75", which is more than the configured time (StuckThreadMaxTime) of "600" seconds. Stack trace:
    Thread-75 "[STUCK] ExecuteThread: '11' for queue: 'weblogic.kernel.Default (self-tuning)'" <alive, in native, suspended, priority=1, DAEMON> {
    jrockit.net.SocketNativeIO.readBytesPinned(SocketNativeIO.java:???)
    jrockit.net.SocketNativeIO.socketRead(SocketNativeIO.java:31)
    java.net.SocketInputStream.socketRead0(SocketInputStream.java:???)
    java.net.SocketInputStream.read(SocketInputStream.java:107)
    weblogic.utils.io.ChunkedInputStream.read(ChunkedInputStream.java:149)
    java.io.InputStream.read(InputStream.java:85)
    com.certicom.tls.record.ReadHandler.readFragment(Unknown Source)
    com.certicom.tls.record.ReadHandler.readRecord(Unknown Source)
    com.certicom.tls.record.ReadHandler.read(Unknown Source)
    ^-- Holding lock: com.certicom.tls.record.ReadHandler@bec563c[thin lock]
    com.certicom.io.InputSSLIOStreamWrapper.read(Unknown Source)
    java.io.BufferedInputStream.fill(BufferedInputStream.java:189)
    java.io.BufferedInputStream.read(BufferedInputStream.java:236)
    ^-- Holding lock: java.io.BufferedInputStream@bec5d9f[thin lock]
    weblogic.net.http.MessageHeader.isHTTP(MessageHeader.java:214)
    weblogic.net.http.MessageHeader.parseHeader(MessageHeader.java:141)
    weblogic.net.http.HttpClient.parseHTTP(HttpClient.java:452)
    ^-- Holding lock: weblogic.net.http.HttpsClient@bec5202[thin lock]
    weblogic.net.http.HttpURLConnection.getInputStream(HttpURLConnection.java:328)
    weblogic.net.http.SOAPHttpsURLConnection.getInputStream(SOAPHttpsURLConnection.java:37)
    ^-- Holding lock: weblogic.net.http.SOAPHttpsURLConnection@bd3b209[thin lock]
    weblogic.net.http.HttpURLConnection.getResponseCode(HttpURLConnection.java:939)
    com.sun.xml.ws.transport.http.client.HttpClientTransport.readResponseCodeAndMessage(HttpClientTransport.java:213)
    com.sun.xml.ws.transport.http.client.HttpTransportPipe.process(HttpTransportPipe.java:116)
    com.sun.xml.ws.transport.http.client.HttpTransportPipe.processRequest(HttpTransportPipe.java:101)
    com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:580)
    com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:553)
    com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:535)
    com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:433)
    ^-- Holding lock: com.sun.xml.ws.api.pipe.Fiber@bd3afa8[thin lock]
    com.sun.xml.ws.client.Stub.process(Stub.java:238)
    com.sun.xml.ws.client.sei.SEIStub.doProcess(SEIStub.java:135)
    com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:102)
    com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:89)
    com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:116)
    $Proxy107.jobSubmit(Unknown Source)
    com.somejob.invokeService(JobOperation.java:53)
    com.somejobws.operations.ticket.execute(ticket.java:30)
    com.somejobutil.Somehelper.process(Somehelper.java:174)
    com.somejobutil.Somehelper.processJob(Somehelper.java:147)
    com.somejobutil.Somehelper.processMDB(Somehelper.java:91)
    com.somejobejb.ProcessMDB.onMessage(ProcessMDB.java:28)
    sun.reflect.GeneratedMethodAccessor109.invoke(Unknown Source)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    java.lang.reflect.Method.invoke(Method.java:575)
    com.bea.core.repackaged.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
    com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
    com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:148)
    com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
    com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:102)
    com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:148)
    com.bea.core.repackaged.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:86)
    com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:148)
    com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
    com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:102)
    com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:148)
    com.bea.core.repackaged.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:151)
    $Proxy67.onMessage(Unknown Source)
    weblogic.ejb.container.internal.MDListener.execute(MDListener.java:403)
    weblogic.ejb.container.internal.MDListener.transactionalOnMessage(MDListener.java:352)
    weblogic.ejb.container.internal.MDListener.onMessage(MDListener.java:264)
    weblogic.jms.client.JMSSession.onMessage(JMSSession.java:4564)
    weblogic.jms.client.JMSSession.execute(JMSSession.java:4060)
    weblogic.jms.client.JMSSession.executeMessage(JMSSession.java:3746)
    weblogic.jms.client.JMSSession.access$000(JMSSession.java:114)
    weblogic.jms.client.JMSSession$UseForRunnable.run(JMSSession.java:5096)
    weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:516)
    weblogic.work.ExecuteThread.execute(ExecuteThread.java:198)
    weblogic.work.ExecuteThread.run(ExecuteThread.java:165)
    }

    Yes, we have the same problem, stuck thread on weblogic.net.http.HttpsURLConnection.getResponseCode() (actually implemented by weblogic.net.http.SOAPHttpsURLConnection which also appears to be deprecated ???)
    When we use the class javax.net.ssl.HttpsURLConnection the getResponseCode() method works perfectly well, so it looks like the weblogic implementation is to blame.
    This is becoming rather urgent now because we're looking to migrate from OC4J to Weblogic and this issue has therefore become a blocker.

  • Problem with HttpURLConnection and HttpSession.

    Hi,
    Problem with HttpURLConnection and HttpSession.
    I created a HttpSession object in my main class and then called a URL via HttpURLConnection.
    I tried to access the same session object from the servlet called by the URL . but the main session
    is not returned a new seperate session is created.let me know how can we continue the same session in
    the called URL also which is created in main class.
    Thanks
    Prasad

    You are not supported to create a HttpSession by java client. Only J2EE web container can create it.

  • Lost document on my new MAC because I accidentally saved on another account that I had no permission to save to..now I don't know where the doc is but I just know its somewhere on the computer..maybe the temp files or something?!sos! please help me!!

    I saved a document, while logged in as a Guest, to another user account [it was set up for some reason to save like that (I guess the person who used computer last did that) and I didn't check before "saving"] on accident. Of course I didn't have permission to save on the other user's account but I was in a rush and so I figured everything was fine but later I found that there was a message warning me saying it did not save because it couldn't save because I had no permission to save on that account and gave me the option to duplicate or cancel.. I wasn't paying attention so I can't remember which button I hit but clearly it wasn't "duplicate"
    I took hours perfecting this document and now I can't find it.. anywhere!
    Where do these types of things go when this happens.. I know it's somewhere on the computer but where?? SOS I need the doc and I'm hoping I can find it
    I guess it's the same as someone who accidnetly hits "don't save"... question still stands.. please anyone help me!!!
    I'm trying to use Disk Drill but I only found things from November and it seems like it only shows files that have been physically/manually deleted..and my TIME MACHINE WAS NOT SET UP..because we recently got this MAC computer and had no clue what it was
    maybe its in some temp files somewhere..where do not saved documents go.. i know that it is probably writable but I know that is probably still exists
    ANYONE WITH INFO PLEASE PLEASE HELP!!

    tis true
    I know, I always do that but I was in a rush to get somewhere and I was relying on my thousand dollar Mac to do some kind of recovery or something. I know Microsoft always keeps temporary files (I think Mac does too, part of me asking here in this forum was for someone to tell me where I can find those files) and when you go to open Office Works then it gives you the option of opening the last recent documents, saved or not saved.
    I usually copy paste into my emial just in case something goes wrong with the created document but I just didn't have the time to login and do all that My loss, you live and you learn, BUT still if ANYONE got any info on this, PLEASE DO CHIME IN *keeping the hope alive*

  • HttpURLConnection.connect() takes long time (3 minutes)

    I'm stumped on an unusual problem. I'm running java 1.3 and Apache JServ (don't ask, I inherited this set up), using JSSE. One of the things we do with our app involves some xml communication over SSL.
    Starting last week, the time for the SSL communication jumped from about 15 seconds to around 3 minutes.
    Here is the bit of code that does the actual communication. An example function call would be:
    contactService("ShipConfirm", "ups.app/xml");and the function definition:
    public void contactService(String service, String prefix)  throws Exception {
      HttpURLConnection connection;
      URL url;
      // the next 2 variables are stored elsewhere in the object
      // these values are just examples of one invocation
      String protocol = "https";
      String hostname = "wwwcie.ups.com";
      String urlStr = protocol + "://" + hostname + "/" + prefix + "/" + service;
      // so for this test urlString = "https://wwwcie.ups.com/ups.app/xml/ShipConfirm";
      try  {
        if (protocol.equalsIgnoreCase("https")) {
          java.security.Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
          System.getProperties().put("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol");
        url = new URL(urlString);
        // Trace.log is a convenience class that will print to a log file and include a timestamp
        Trace.log("open connection to " + urlString);
        connection = (HttpURLConnection) url.openConnection();
        // openConnection takes about 20 seconds now, before 1 or 2 seconds
        Trace.log("opened connection to " + urlString);
        connection.setDoOutput(true);
        connection.setDoInput(true);
        connection.setUseCaches(false);
        // XmlIn is an already generated xml file stored in a StringBuffer, declared elsewhere
        String queryString = XmlIn.toString();
        Trace.log("xml connection to " + urlString);
        connection.connect();
        // connect takes about 3 minutes 10 seconds now, before 15 seconds
        Trace.log("xml connection complete " + urlString);
        OutputStream out = connection.getOutputStream();
        out.write(queryString.getBytes());
        out.close();
        String data = "";
        try {
          // on the server this is actually a separate function
          StringBuffer buffer = new StringBuffer();
          BufferedReader reader = null;
          try {
            reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
            String line = null;
            int letter = 0;
            while ((letter = reader.read()) != -1)
              buffer.append((char) letter);
          catch (Exception e) {
            // Trace.major is like Trace.log, but is a higher severity
            Trace.major("Cannot read from URL" + e.toString());
            throw e;
          finally {
            try {
              reader.close();
            catch (IOException io) {
              Trace.major("Error closing URLReader!");
              throw io;
          data = buffer.toString(); // actually a return statement on server
        catch (Exception e) {
          Trace.major("Error in reading URL Connection" + e.getMessage());
          throw e;
        XmlOut = new StringBuffer(data);  // XmlOut is a StringBuffer declared elsewhere
      catch (Exception e1) {
        Trace.major("Error sending data to server" + e1.toString());
    } Besides a couple of new Trace.log statements to pin down the what, exactly, is taking so long, I haven't touched this code in the year+ since I've inherited it. There haven't been any changes in the network setup for the last 3 weeks, either (last change was new reverse lookup zone for our internal network).
    Any idea why the HttpURLConnection.connect() would take so long? Or any idea how I can find out what is going on for those 3 minutes? In my search so far, I found -Djava.net.debug=ssl,handshake,data and added it to my startup parameters, but in my frustration, I must have overlooked what I need do to make it show up in my logs.
    I set up a tcpdump on the server to listen on the IP that I'm trying to connect to and the "xml connection to" log statement prints, then about 3 minutes and 10 seconds goes by, then tcpdump reports that we actually send the packets to the other server, then we get a response and print the "xml connection complete" log message. URL and HttpURLConnection are not subclassed at all.
    To make things even more interesting, I broke out this code, and wrote a small test program. The test program has some minor changes (pulling the xml data from an already existing file, mainly), and this version runs lickety-split (about 5 seconds).
    Any help or pointers would be greatly appreciated. Let me know if I can provide any more information.
    Thanks,
    Andy

    Figured it out..
    The other side removed a proxy server that we used to try to connect through. The server was taking 3 minutes and 10 seconds to time out when it trying to contact the proxy server.
    To be honest, I don't know if we ever successfully connected through the proxy server. I'm inclined to believe we tried to contact it, but were rejected, but no one ever removed the proxy code.
    Andy

  • Open POs for per SOs

    Hi All,
    How can we open POs for per SOs?
    We want open 1 PO concerning all the items in 1 SO..
    So we will try to pack POs seperately for 1 customer.
    Thanks
    Regards
    Siva

    Siva,
    Please remember that a single PO is procured from only one vendor.  It is a rare event when all items in a single SO can be procured from one vendor, and would thereby qualify for inclusion in a single PO..
    You may manually create POs with as many items as you wish.  Once you have determined the materials/qtys you wish to purchase to support a particular SO, just manually enter them all into a single PO.
    Best Regards,
    DB49

  • How to open 2 HttpURLConnections in the same session

    Dear,
    I'm writing a client application that use HTTP GET request to get infomation from a web-server. Before getting any infomation, the web-client need to login.
    When using the browser, I can't get infomation through these steps:
    First, go to the URL login.jsp?username=myUser. This username will be keep in the http session variables. Then, I can get info through the page getinfo.jsp.
    Now, I want to do these steps in my java client app. My code is as follow:
          URL url = new URL("http://myhost:8080/test/login.jsp?username=myUser");
          HttpURLConnection urlCon = (HttpURLConnection)url.openConnection();
          url = new URL("http://myhost:8080/test/getinfo.jsp");
          urlCon = (HttpURLConnection)url.openConnection();I known that the session variables were lost between two openConnection() method.
    So, how can I keep my session variables? (I have no permission to change code of the server).
    Please help me!
    Thanks!

    Sorry - I missed the point about not having permissions on the server.
    In that case, I would try working out how the site normally tracks the session. If it inserts a sessionId in to every link, you need to include that in your request to getInfo.jsp.
    If it uses cookies, look at the headers for a field named "Set-Cookie":
    for (int i=0; ; i++) {
       String headerFieldKey = conn.getHeaderFieldKey(i);
       if ("Set-Cookie".equalsIgnoreCase(headerFieldKey)) {
    }Then use setRequestProperty() to send the same cookie (proably the username or a session id) to getInfo.jsp. I think that will work.
    Make sure you ask the site owner if you are using this for harvesting content!
    --Jon                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Can you Ignore Error Response Code in HttpUrlConnection?

    I have a problem with a HttpUrlConnection object throwing an IOException when it gets an HTTP Error Response code. Especially when there is an actual response from the server sent back that has more details in it that are actually helpful.
    I would like to just tell the HttpUrlConnection ot ignore HTTP error responses and just pass along the page or data that was returned instead. I need to handle this myself.
    The reason if it matters, is I am sending SOAP Envelopes, and if the Web Service doesn't like it, it will send an HTTP 500 Response Code, but it also sends a response SOAP Envelope that tells me exactly what is wrong.
    Right now to get this response I have to use a Sniffer, or worse since it is HTTPS (ssl) i have to use the jvm's SSL debug mode, and pull the response out of the hex code.
    I couldn't find anything about this, so I am afraid I am SOL, just hoping that there might be an obscure "feature" or "property" that can deal with this, that I can't find.
    ** 10 Duke Dollars to first person to provide a solution that works **

    Just call the getErrorStream() method to read the error response. Eg.
    HttpURLConnection conn = null;
    try {
      conn = (HttpURLConnection)
        new URL("http://www.google.com/givemea404").openConnection();
    } catch (Exception e) {
      InputStream in = conn.getErrorStream();
      int i = in.read();
      while (i != -1) {
        System.out.print((char) i);
        i = in.read();
    }

  • Can I log in a site only with HttpUrlConnection?

    I'm trying to write a small program which help me to log into my Megaupload account and manage my own stuffs there. But I met a obstacle right from the start, login site.
    After reading some of Sun's ["working with URLs" lesson|http://java.sun.com/docs/books/tutorial/networking/urls/index.html] and searching around, I've tried coding a small method to do this step. As the following:
    try{
           URL mega = new URL("http://megaupload.com/?c=login");
           String data = URLEncoder.encode("login=1&
                                                            redir=1&
                                                            username=my_username&
                                                             password=my_password","UTF-8");
            HttpURLConnection connection = (HttpURLConnection)mega.openConnection();
            connection.setRequestMethod("POST");
            connection.setRequestProperty("Host", "megaupload.com");
         connection.setRequestProperty("Cookie", cookie);
         connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 ( .NET CLR 3.5.30729)");
         connection.setRequestProperty("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
            connection.setRequestProperty("Accept-Language", "en-us, en;q=0.5");
         connection.setRequestProperty("Accept-Encoding", "gzip,deflate");
         connection.setRequestProperty("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7");
         connection.setRequestProperty("Keep-Alive", "115");
            connection.setRequestProperty("Connection", "keep-alive");
         connection.setRequestProperty("Referer", "http://megaupload.com/?c=login");
         connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
         connection.setReadTimeout(10000);
         connection.setRequestProperty("Content-Length", Integer.toString(data.getBytes().length));
         connection.setDoInput(true);
         connection.setDoOutput(true);
            DataOutputStream wr = new DataOutputStream(connection.getOutputStream());
         wr.writeBytes(data);
         wr.flush();
         wr.close();
           //Codes to reading the response from MU
    }catch(Exception e){
    }The headers i receipt was exactly the same as using Firefox, but the html body was always of the login site instead of redirecting to the home page with logged in status. After some failed attempts to solve it myself, I came up searching help from this forum, and realized that there's lots of problem similar to mine. However, not any of them is absolutely solved without using external libraries (HttpsClient). I wonder if I can do it only with existing internal libraries. If yes, what I need to do?
    Thanks in advanced for help, and sorry for my bad English.

    I modified it:
    String data  = URLEncoder.encode("login", "UTF-8") + "=" + URLEncoder.encode("1", "UTF-8");
    data  += "&" + URLEncoder.encode("redir", "UTF-8") + "=" + URLEncoder.encode("1", "UTF-8");
    data  += "&" + URLEncoder.encode("username", "UTF-8") + "=" + URLEncoder.encode("chihuongbk", "UTF-8");
    data  += "&" + URLEncoder.encode("password", "UTF-8") + "=" + URLEncoder.encode("19881026h", "UTF-8");
    ..........Got the same result. I think that's not the problem. I feel there is something missing. Can you tell me whether I can log in the site this way with some more modifications !??

  • How do i close the welcome to iMovie screen? Clicking on red button in upper left does nothing. SOS!  Thanks!

    How do I close the "Welcome to iMovie" screen?  Clicking on the red button in the upper left does nothing. SOS!  Thanks!

    "Continue" was hidden at the bottom of the welcome screen because my display was changed.  Some days I'm smarter than others.  Or.... :-) 

  • How to set HttpURLConnection timeout while reading a stream?

    I want it got time out if the connection if lose while i read a stream from URL
    try {
         int timeout = 700;
         HttpURLConnection connection = (HttpURLConnection) downloadURl.openConnection();
         connection.setConnectTimeout(timeout);
         connection.setRequestProperty("Range","bytes=" + downloaded + "-");
         connection.connect();
         if (connection.getResponseCode() / 100 != 2) {
              error();
         int contentLength = connection.getContentLength();
         if (contentLength < 1) {
              error();
         if (status == DOWNLOADING){
              if (size == -1) {
                   size = contentLength;
              file = new RandomAccessFile(saveTmpName+".tmp", "rw");
              file.seek(downloaded);
         byte buffer[];
         stream = connection.getInputStream();
    connection.setReadTimeout(timeout);
         while (status == DOWNLOADING) { 
              if (size - downloaded > MAX_BUFFER_SIZE) {
                   buffer = new byte[MAX_BUFFER_SIZE];
              } else {
                   buffer = new byte[(int)(size - downloaded)];
              int read = stream.read(buffer); // how to set timeout while it is reading stream
              if (read <= 0)
                   break;
              file.write(buffer, 0, read);
              downloaded += read;
         if (status == DOWNLOADING) {
              status = COMPLETE;
    } catch (SocketTimeoutException  e) {
         error();
    } catch (IllegalArgumentException e) {
         error();
    } catch (Exception e) {
         error();
    } finally {
         if (file != null) {
              try {
                   file.close();
              } catch (Exception e) {}
         if (stream != null) {
              try {
                   stream.close();
              } catch (Exception e) {}
    }I try to set "setReadTimeout()" but is still not through timeout Exception

    ejp wrote:
    Because, there's no FTP client command that allows to do such thing.Socket.setSoTimeout().I agree with you on this one but the OP is talking about the FTPClient API from Apache.
    To the OP,
    BTW, I have reread the Javadoc about the [*API*|http://commons.apache.org/net/api/org/apache/commons/net/ftp/FTPClient.html] : indeed, there's no setTimeout method, but there is a setDataTimeout method : +Sets the timeout in milliseconds to use when reading from the data connection+ .

  • SOS: JSON and internet explorer

    hi -- I posted the following a few days ago:
    JSON error in internet explorer 8 -- works fine in Firefox
    I haven't heard anything back yet from the forum, so thought I'd send out another SOS.
    I filed an SR, but this is outside the realm of Oracle Support's expertise.
    Anyone had trouble w/ JSON and IE?
    Thanks,
    Carol

    See this page.. (Look for area under native json obkject) [http://blogs.msdn.com/ie/archive/2009/03/12/site-compatibility-and-ie8.aspx] it's possible you are getting hit with this issue..
    Thank you,
    Tony Miller
    Webster, TX

  • SOS only, No Service and searching for network

    Need help!! Very little beer spilled on my iPhone 4 where the speaker and front camera is and was wiped try immediately. It was still working fine after the incident for a few days however, suddenly the iPhone started playing up and losing reception and now its started showing SOS only then it says No Service and switches back and forth from No Service to searching.
    I've tried...
    Turing on/off airplane mode
    Taking SIM out then putting it back in
    Putting another SIM in iPhone both Telstra SIM and Optus
    Putting iphone in container of rice for hours
    Restore network settings
    Hard reset iphone (holding sleep/home key)
    Updating iTunes version
    Sync -> back up iPhone -> restore iphone -> sync and back up iPhone from previous back up's -> restore back up again just to be on the safe side but there's no change and keeps switching from No Service to searching.
    Telstra is not sure whats wrong and has advised to take it to Apple or Telstra store for assessment and sent of to get fixed.
    Does anyone know why this is happening or what I can do to fix it without having to fork out money if possible as not covered by warranty anymore.

    Disregard this post, I have resolved my issue, thank you

  • 500 Error code while consuming web service using HTTPURLConnection

    Hi,
    I am getting an HTTP response code 500 and an IOException when I run a web service client to invoke a BMC Remedy web service (document based). I am using XML over HTTP to hit the web service as follows:
    // For Remedy
    soapAddress = "http://www.test-sislhelpdesk.siemens.co.in/arsys/services/ARService?server=bomw041a&webService=WebService_Test";
    soapEnvelope = "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><SOAP-ENV:Header><AuthenticationInfo><userName>webservice</userName><password>*******</password></AuthenticationInfo></SOAP-ENV:Header><SOAP-ENV:Body><Q1:OpGetList xmlns:Q1=\"urn:WebService_Test\"><Q1:Qualification></Q1:Qualification></Q1:OpGetList></SOAP-ENV:Body></SOAP-ENV:Envelope>";
    soapAction = "urn:WebService_Test/OpGetList";
         URL url = new URL(soapAddress);
         HttpURLConnection connection = (HttpURLConnection) url.openConnection();
         System.out.println ("Connection got");
         connection.setDoOutput(true);
         connection.setRequestProperty("Content-Type","text/xml");
         connection.setRequestProperty ("soapAction", "\"" + soapAction + "\"");
         OutputStreamWriter outputStream = new OutputStreamWriter(connection.getOutputStream());
         System.out.println ("outputstream got");
         outputStream.write(soapEnvelope);
         outputStream.flush();
         BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
         String line = null;
         while ((line = reader.readLine()) != null)
              writer.write(line);
              writer.write("\n");
         System.out.println (writer);
         catch(Exception e){
              e.printStackTrace();
    I have created a .NET client proxy which seems to work well.
    I am not able to figure out as to why this code is not working. May be something wrong with the SOAP message request I am sending? But I have created this SOAP request message from the log generated for a successful hit. Any help in this regard will be highly appreciated.
    The web service is on the internet and hance is accessible to all :)
    Regards
    Vaibhav

    Tried "POST" request method, did not work.
    Actually when i hit other web services (created by me) , the code works.
    But when I hit a third party web service, it fails returning 500 error code.
    How can I extract the SOAP message returned, if any and see thinggs for myself.
    I guess there is something wrong with the request SOAP message which I am sending.

Maybe you are looking for

  • Problem opening Office documents from KM

    Hello, I have some problem opening Office documents from KM. We stored a lot of office documents (Excel, Word ecc.) in a File System repository (the standard repository "/documents"), when I open one of these files, before to view the document, a lit

  • Error handling : File( sender and receiver)

    Hi Experts, This is regarding some information i require in the Error Handling mechanisms we can use while picking up the file through File Sender Adapter and while placing the same on the receiver adapter : Scenarios like : a)  Validations we can pu

  • I just downloaded mountain lion and now my google chrome and spotify wont open

    I just downloaded mountain lion and now my google chrome and spotify wont open.  Any help would be appreciated.

  • Regarding the select query

    Hi Experts, I have a select query as follows: select field1 field2  from db1 into table it1. Now suppose the it1-field1 contains values a,b and c. Now I want to select fields a,b and c from another db table db2. Instead of hard coding like this: sele

  • Graph cursor box diamonds

    I have a graph with the cursor legend visible.  There is a box with four diamonds next to the cursor legend, and the four diamonds allow the users to move the cursors.  Since I allow cursors dragging on my graph, there is really no reason for the dia