Only 48 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



  • Post Reply Bookmark Topic Watch Topic
  • New Topic

I'm going crazy  RSS feed

 
Elías Turbay
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, sorry for my poor english

I have a very uncommon problem

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

PLEASE HELP ME

Thanks in advance
 
amit punekar
Ranch Hand
Posts: 544
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
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.

 
John Kimball
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess two obvious questions are:
- Are you sure it's sucessful?
- What do you get if you use a regular client--Java class on a PC for instance--to send a request to the problem server?
 
Elías Turbay
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi amit,

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

Thanks for reply
 
Elías Turbay
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi John

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

Thanks a lot for your help
 
John Kimball
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
- 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!