Results 1 to 3 of 3
  1. #1
    edo_nick is offline Member
    Join Date
    Mar 2011
    Posts
    3
    Rep Power
    0

    Default Java Applet different results in IDE and browser

    Hi.
    I am newbie in Java but I have first steps behind myself.
    Using Eclipse IDE I create applet which reads webpages and prints out
    extractraction results.
    Sometimes applet in browser shows wrong results. It looks like content of
    some pages was readed some days ago. But when I run it in Eclipse IDE
    everything is all right. What is going wrong?

    Here is reading method:
    public static byte[] getBytesFromUrl(URL iurl) throws IOException,
    InterruptedException {
    ByteArrayOutputStream tmpOut = new ByteArrayOutputStream();
    HttpURLConnection urlConn = (HttpURLConnection) iurl.openConnection();
    urlConn.setDefaultUseCaches(false);
    urlConn.setDoInput(true);
    urlConn.setDoOutput(true);
    urlConn.setUseCaches(false);
    urlConn.setRequestMethod("GET");
    urlConn.setRequestProperty("Pragma", "no-cache");
    urlConn.setRequestProperty("Cache-Control", "no-cache");
    InputStream openStream = new BufferedInputStream(urlConn.getInputStream());
    byte[] buf = new byte[16384];
    int len;
    while (true) {
    len = openStream.read(buf);
    if (len == -1) {
    break;
    }
    tmpOut.write(buf, 0, len);
    }
    tmpOut.close();
    ByteBuffer bb = ByteBuffer.wrap(tmpOut.toByteArray(), 0, tmpOut.size()
    );
    byte[] binaryData = tmpOut.toByteArray();

    //byte[] binaryData = new byte[contentLength];
    //openStream.read(binaryData);
    openStream.close();

    return binaryData;
    }

  2. #2
    dswastik is offline Senior Member
    Join Date
    Dec 2008
    Location
    Kolkata
    Posts
    282
    Rep Power
    6

  3. #3
    edo_nick is offline Member
    Join Date
    Mar 2011
    Posts
    3
    Rep Power
    0

    Default

    Please be more accurate. My JAR is signed to run applet on web. I think there is no problem.

Similar Threads

  1. Replies: 8
    Last Post: 03-10-2011, 07:00 PM
  2. No sound when applet is in browser
    By Ambergahill in forum New To Java
    Replies: 5
    Last Post: 11-21-2010, 06:40 AM
  3. Output console results to a HTML browser
    By JTS25 in forum New To Java
    Replies: 5
    Last Post: 11-04-2010, 06:25 PM
  4. Applet with Images in Browser
    By baron in forum Eclipse
    Replies: 0
    Last Post: 09-20-2009, 10:06 PM
  5. applet won't run in browser...
    By shwein in forum Java Applets
    Replies: 6
    Last Post: 10-17-2008, 06:24 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •