File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java Micro Edition and the fly likes HTTP Post on UMTS stops Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "HTTP Post on UMTS stops" Watch "HTTP Post on UMTS stops" New topic

HTTP Post on UMTS stops

Tilman Bender

Joined: Mar 16, 2008
Posts: 11
Hi there I modified the code from this thread to suit the needs of J2ME:

Modifications I made:

* Use instead of URLConnection
* Use String.getBytes() as DataOutputStream.writeBytes(String s) is not available in MIDP
* Use FileConnection from JSR-75 FileConnection API

I use it like this:

While the code seems to work well with GPRS, I experienced problems with UMTS.
Here are my test results:

||Java Plattform||JP-8JP-8JP-8JP-8JP-8JP-8
||Filesize (Byte)||1.428.0771.428.0771.428.0771.428.0771.428.0781.428.079
||Upload (Byte)||completecompletecompletecomplete184320 (113664)627712 (199680)

The problem of partial upload seems only to exist with larger Files (not sure where exactly the lower bound is).

I hope this was not too much information for a start, but I am currently quite desperate about this bug.
I could really use some help here. I will also provide you with the results of a test on Nokia S60 phones
and the results of SE on device debugging.

[ April 03, 2008: Message edited by: Tilman Bender ]
Sorry could not manage to get my results formatted any better.
[ April 03, 2008: Message edited by: Tilman Bender ]
Tilman Bender

Joined: Mar 16, 2008
Posts: 11
The issue was solved by a firmware upgrade
Must have been a problem with JP-8. Works as expected on JP-8.2 now.

Java PlattformJP-8.2JP-8.2
Carrier VodafoneVodafone
Filesize (Byte)1.428.0771.428.077
Upload (Byte)completecomplete

jackie zho

Joined: May 26, 2008
Posts: 1
Hi Tim,
I am trying to do http post with multipart/related content type. I wrote the code but it always gives exception when binary data starts to be written. can you look at see what is wrong? Thanks

c = (HttpConnection);
String axml="<?xml version='1.0'?><entry xmlns='' " +
"xmlns:media='' xmlns:yt=''>" +
" <media:group> <media:title type='plain'>Bad Wedding Toast</media:title>" +
" <media escription type='plain'> I gave a bad toast at my friend's wedding." +
" </media escription> <media:category" +
" scheme=''>People" +
" </media:category> <media:keywords>toast, wedding</media:keywords>" +
" </media:group></entry>";
// Set the request method and headers
c.setRequestProperty("Host", "");
c.setRequestProperty("Authorization", "GoogleLogin auth="+appM.utubeAuth);
c.setRequestProperty("X-GData-Client", appM.clientid);
c.setRequestProperty("X-GData-Key", "key="+appM.developerkey);
c.setRequestProperty("Slug", "myvideo.3gp");
c.setRequestProperty("Content-Type", "multipart/related; boundary="+BOUNDARY);
// String consize=new String()

String message1 = "";
message1 += "--"+BOUNDARY + CrLf;
message1 += "Content-Type: application/atom+xml; charset=UTF-8" + CrLf+ CrLf;
message1 += axml;
message1 += CrLf+"--"+BOUNDARY + CrLf;
message1 += "Content-Type: video/3gpp" + CrLf;
message1 += "Content-Transfer-Encoding: binary" + CrLf+ CrLf;
// the image is sent between the messages in the multipart message.

String message2 = "";
message2 += CrLf+"--"+BOUNDARY + "--";

String contlen=(new Long(appM.blockSize[2]+message1.length()+message2.length())).toString();
c.setRequestProperty("Content-Length", contlen);

c.setRequestProperty("Connection", "close");
os = c.openOutputStream();

// os.write(appM.anim[2]);
int index = 0;
int size = 1024;
System.out.println("write:" + index);
size = appM.anim[2].length - index;
os.write(appM.anim[2], index, size);

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17256

What's the exception?

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: HTTP Post on UMTS stops
It's not a secret anymore!