My J2ME app communicates with a Tomcat Server (RPC pattern). I have only one Servlet that execute differents methods based on the operation requested by the MIDlet.
The MIME TYPE is set as response.setContentType("application/binary"); And I'm using DataInputStream and DataOutputStream in both sides
When the operation was successful, the Servlet send an int constant (public static final int opOK = 10;) to the device. The problem is that when the MIDlet does:
din.readInt() it doesn't read the value 10, it read this value: 1008813135
The server that have this behavior is a Linux Server (behind a Windows 2003 Server with a port fowarding configured at 8080 port). We try to solve this reinstalling the JDK with a newer and also reinstaling an older Tomcat, but nothing happens.
I ran the same Web app in other Server (Windows XP) of another company and everything goes well. In that case the portfowarding is configured in the ADSL router.
But I need this application to function correctly in the another environment
I guess you are sending int 10 as the success code from your servlet.
Instead of relying on this why dont you check the RESPONSE code that is returned in the HttpServletResponse.
I have not worked with J2ME application but I assume that if you are connecting to Servlet in J2ME application, there would be a way to get handle the response headers.
P.S: Response Code 200 represents the successful response.
I cannot use your aproach 'cause the operations that the Servlet executes has multiple responses.
Response Code 200 represents a successful conexion, but after that, several operations that can return different values
I'm sure that the Servlet execution is successful for two reasons. First I have read all the Tomcat logs and there are no errors. Then I made an error handler Class that is called inside all catch instructions, and save the error to the database, but nothing is inserted. I have forced an error, and then I saw that the error handler class saved it correctly.
For the second question... I add another Servlet that does exactly the same but change the type of response to "text/html" and use PrintWriter to output the response to the Browser and the result is correct. I get the value 10
- What happens if you eliminate Windows 2003 from the equation? Are the forwarded packets somehow getting altered?
Not unheard of, though it's not something I'd expect.
- Likewise, you can try eliminating the Linux server, though that would be far more work
- I'm a bit uneasy with the public static final. Just because. But since you're getting the correct value via text/html I'm sure it can't be a factor.
Sorry, I'm not being very helpful here but I find this problem interesting.
Our first order of business must be this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth