acessing servlets from j2me midlets
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   guru_prasanth
Posted On:   Sunday, June 16, 2002 06:28 PM

hi,
i am sending some information from j2me midlets to servlet and try to retrive data.but i got http.getLength
value is -1 and iam not able to retrive data from servlets.can some one explain me why it happens.

Re: acessing servlets from j2me midlets

Posted By:   Ferdinand_Alimadhi  
Posted On:   Monday, June 17, 2002 11:01 AM

(Sorry if I'm missundersanding your question...)

Even your http.getLength is -1,I think that doesn't mean
that you are not able to retrive data.

Maybe you have the data but you have to read them.


For example try something like this:


.....

InputStream iStrm = null;

.....


int length = (int) http.getLength();

StringBuffer sb =new StringBuffer();

if (length != -1)

{

for (int i=0;i


if ((ch=iStrm.read())!=-1) {

sb.append((char)ch);

}

}

else // Length not available...

{

while ((ch=iStrm.read())!=-1) {

length=iStrm.available();

sb.append((char) ch);

}

.....



Cheers,

Ferdinand
About | Sitemap | Contact