×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Jan 2006
    Posts
    6

    WTK23 and Nokia 6630 behaves differently

    my program behaves differently on the following condition;

    i have a servlet which generates a XML file and i have a class on which i can read this file over http.

    On WTK23 i debug the code and see that the generated XML file has length 111, but same code running on 6630 reads 109 bytes and then hangs !!

    I notice that using Transformer for XML generation results in length -1 (see code below). if i use repsonse.getWriter().println() and write the XML manually for testing in that case the length is 111 on both WTK23 and 6630.

    what might be the problem?

    Transformer implementation on Apache Tomcat cause HttpConnection to fail on Nokia 6630?
    HttpConnection have problems when length = -1?
    missing 2 byte (111 - 109 = 2) might be length or encoding problem?

    The strange thing that i notice is that Nokia 6630 hangs on read and never returns after reading 109 bytes.

    Thanks in advance,

    Niyazi


    Below is some portion of my code;

    Servlet code which generates XML;
    Application Server is Apache Tomcat 5.5.15

    try {

    response.setContentType("text/html");
    response.setCharacterEncoding("UTF-8");

    DocumentBuilderFactory factory = DocumentBuilderFactory.
    newInstance();

    Document doc = factory.newDocumentBuilder().newDocument();

    Element reply = (Element) doc.createElement("subscription");
    doc.appendChild(reply);

    reply.setAttribute("username", username);
    reply.setAttribute("status", "Active");
    ...

    TransformerFactory xfFactory = TransformerFactory.newInstance();
    Transformer transformer = xfFactory.newTransformer();

    transformer.transform(new DOMSource(doc), new StreamResult(response.getWriter()));

    } catch (Exception e) {
    }



    J2ME code which reads over HTTP

    c = (HttpConnection) Connector.open(url);
    c.setRequestMethod(HttpConnection.GET);

    is = c.openInputStream();
    if (c.getResponseCode() == HttpConnection.HTTP_OK) {
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    int b;
    while ((b = is.read()) != -1) {
    receiver.readnotify(id, bos.size(), c.getLength());
    bos.write(b);
    }
    receiver.readnotify(id, bos.size(), c.getLength());
    receiver.received(id, url, bos.toByteArray());
    } else {
    receiver.failure(id, url);
    }

  2. #2
    Registered User
    Join Date
    Jan 2006
    Posts
    6

    Re: WTK23 and Nokia 6630 behaves differently

    Same issues on Nokia Prototype SDK 4.0.
    It works correctly on simulator but not on the phone (nokia 6630)

  3. #3
    Registered User
    Join Date
    Jan 2006
    Posts
    6

    Re: WTK23 and Nokia 6630 behaves differently

    adding one line of code changes behaivour !!!

    c = (ContentConnection) Connector.open(url);
    sleep(1000); // added line


    in that case my 6630 reads 111 bytes but still hangs !!!!

    please note that my other phone Nokia 6681 returns with
    reading data of length = 0;

Posting Permissions

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