Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

content-length in http , depends on what ?

Posted on 2004-10-25
13
Medium Priority
?
187 Views
Last Modified: 2010-07-27

I have a mobile application that downloads some data from web-server database , it was working fine with the mobile 6610 before from same place, but now it is not working properly !,
 
- What happenned is, when I get the data using the php code resides in my server it was not returning the "length" of the packet , but now it is returning the length ( using http.getLength() method in java, normally was returing -1 , but now returning 93 for some strange reason !!! )  can yopu help me please what could be happenning ?!, returning or not returning the packet length depends on what ?

- Also I tried to handle the data reception when length is available, but something is still wrong
herein the code
      if( len != -1) {      debug="6";
             for(int i =0 ; i < len ; i++ ){
                   ch = iStrm.read();
                   bStrm.write(ch);      debug="7"; //it stops here !
              if (ch == 10) { // incase length is available, no detection of ch==10 or 13
                        vStr.addElement(bStrm.toString());
                                  bStrm.reset();
                       }
      }
      }
            else
            while ( (ch = iStrm.read()) != -1) {
                    bStrm.write(ch);
                  if (ch == 10) {
                    vStr.addElement(bStrm.toString());
                    bStrm.reset();
            }
      } // while


- one important point is why the length always returning 93 even if the data is more , I know in http it comes in chunks , but not chunks of 93 bytes !


thanks very much for your help !
0
Comment
Question by:khamouda
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
  • 2
13 Comments
 
LVL 13

Expert Comment

by:petmagdy
ID: 12398940
please i don't understand, what changed in the application to become not working, the device or the Web components?
0
 
LVL 1

Author Comment

by:khamouda
ID: 12398957

I am not sure actually, I even posted a question to my web hosting company if they have changed any thing !. Actually the application is working fine with some mobiles ( latest mobiles ) but with nokia 6610 & 6220 it was working fine , but now it is not !!!, in 6220 I got an exception :missing CRLF  ( I think it means carriage return line feed ) , this is why I tried to change the line if ( ch == 10 ) to ch== 13 or both , but still some thing has been changed in the received data format

thanks
0
 
LVL 13

Accepted Solution

by:
petmagdy earned 375 total points
ID: 12398988
ok take care that 6610 and 6220 is series 30 or 40 they are limited to 64 K RAM only!! so probably if the return HTML is very long it will not work, concentrate on Series 60 mobiles like 3650, 3660
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 1

Author Comment

by:khamouda
ID: 12399018
can you comment on this :

but now it is returning the length ( using http.getLength() method in java, normally was returing -1 , but now returning 93 for some strange reason !!! )  can yopu help me please what could be happenning ?!, returning or not returning the packet length depends on what ?
0
 
LVL 13

Expert Comment

by:petmagdy
ID: 12399042
one more question r u using MIDP 1.0 or 2.0?
0
 
LVL 13

Expert Comment

by:petmagdy
ID: 12399136
try to search for ur problem at:

http://www.forum.nokia.com/main.html

specify in ur search the nokia model has the problem
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12399500
A client application should not rely on the content length being provided. It should simply read until EOF
0
 
LVL 1

Author Comment

by:khamouda
ID: 12408303

the problem actually with the midp1. Reading until the EOF ( -1 )  could not finish if the length is indicated, I read it somewhere

0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12409780
>>could not finish if the length is indicated

I find that hard to believe. I don't normally deal with J2ME. Can you post a link to the API docs?
0
 
LVL 13

Expert Comment

by:petmagdy
ID: 12409910
khamouda
This is a device specific problem u need to return to the manifacturer site to see if this problem is reported and what to do about it, if it is not fixed concentrate on the devices that works.

I saw even worth cases while I was developing J2ME products different devices and vendors and series and models is a big miss u must focus on the reliable devices for ur application and the devices u r mentioning that has the problem is not suitable for applications that deal with networks it is only 64 K RAM
0
 
LVL 13

Expert Comment

by:petmagdy
ID: 12628807
Hi Venabili

My advice was quite correct, because I worked on J2ME devices before and I know (and faced actually) that the mentioned problem can be device specific, means specific for the mobile model used
0
 
LVL 1

Author Comment

by:khamouda
ID: 12633240

please magdy can u help in this question http://www.experts-exchange.com/Programming/Wireless_Programming/Q_21199559.html

is their any WAP APto be used in J2ME ,  I I think it is a good idea to write one !

khaled
0

Featured Post

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question