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);
}