Writing Java code for HTTP POST in a J2ME environment

R

Rishabh

Hi Gurus,
I am quite a newbie to Java programming itself! Given this, I need,
for a work related project, to write some code in Java to create a
HTTP POST message. This POST message will be sent to a server which
will respond to the POST with a simple "echo" of the body of the POST.
Can anybody possibly guide me to a suitable website where I can find
such a piece of code?

Your help is much appreciated!

Regards,
-Rishabh
 
D

Darryl L. Pierce

Rishabh said:
Hi Gurus,
I am quite a newbie to Java programming itself! Given this, I need,
for a work related project, to write some code in Java to create a
HTTP POST message. This POST message will be sent to a server which
will respond to the POST with a simple "echo" of the body of the POST.
Can anybody possibly guide me to a suitable website where I can find
such a piece of code?

Your help is much appreciated!

HttpConnection conn = (HttpConnection )connector.open("http://foo.bar");

conn.setRequestMethod(HttpConnection.POST);
conn.openOutputStream();
output.write(data);
conn.setRequestProperty("Content-length",String.valueOf(data.length));

int rc = conn.getResponseCode(); // done!
 
R

Roedy Green

Dude, you need to read the message and/or the subject. The guy was asking
how to do HTTP POST within the MIDP/J2ME environment.

It provides the code to do it in ordinary java. It also links to code
to do it with raw sockets. That should be sufficient to deal with any
features MIDP lacks.
 
R

Roedy Green

Dude, you need to read the message and/or the subject. The guy was asking
how to do HTTP POST within the MIDP/J2ME environment. Your URL speaks
nothing on this subject and would be somewhat misleading to the newbie
neophyte coder.

The poster hid that crucial piece of information in the title off to
the right where it did not even display. Posts should be self
contained.

Even so, questioners are not entitled to precise answers to their
questions. Ones that complain are like a Bush brat born with silver
spoon up his ass who imagines the function of the rest of humanity is
to serve him.
 
D

Darryl L. Pierce

Roedy said:
The poster hid that crucial piece of information in the title off to
the right where it did not even display. Posts should be self
contained.

Well, I wouldn't say he hid it. I would say that your newsreader hid it.
But, the point being, he was asking for X and he was given Y.
Even so, questioners are not entitled to precise answers to their
questions. Ones that complain are like a Bush brat born with silver
spoon up his ass who imagines the function of the rest of humanity is
to serve him.

What has this to do with the currently thread? The OP didn't complain.
 
D

Darryl L. Pierce

Roedy said:
It provides the code to do it in ordinary java. It also links to code
to do it with raw sockets. That should be sufficient to deal with any
features MIDP lacks.

The MIDP doesn't lack APIs to do HTTP. As a matter of fact, the MIDP
requires HTTP functionality and does not provide raw sockets, so showing
how to do HTTP manually is less than useful for the MIDP developer.

Do you have any experience with the MIDP?
 
R

Roedy Green

Well, I wouldn't say he hid it. I would say that your newsreader hid it.

Correct, but any post should repeat any crucial information in the
title.

I am not familiar with MIDP. He asked the question in the generic Java
programming group. Sometimes J2SE answers are useful, sometimes not.

I think it would be foolish to shut up entirely just because I don't
know MIDP.

He presented himself as a newbie who was probably not familiar with
the J2SE solutions either.

What annoys me is the sense of entitlement behind your words, as if
questioners DESERVED perfect answers handed to them on a plate. The
best they can usually hope for are hints. If the hints are not
sufficient TOUGH. Don't blame those trying to help.
 
D

Darryl L. Pierce

Roedy said:
Correct, but any post should repeat any crucial information in the
title.
Absolutely.

I am not familiar with MIDP. He asked the question in the generic Java
programming group. Sometimes J2SE answers are useful, sometimes not.

Sometimes. Too bad we don't have a MIDP/J2ME group, but I dare say that such
would really be unnecessary at this point. Between the OEM-specific mailing
lists and the generic KVM-INTEREST mailing list, there's not much call for
a dedicated newsgroup as well. Perhaps if/when the day comes that the c.l.j
hierarchy breaks out a J2SE and J2EE group...
I think it would be foolish to shut up entirely just because I don't
know MIDP.

Nobody suggested that.
He presented himself as a newbie who was probably not familiar with
the J2SE solutions either.

What annoys me is the sense of entitlement behind your words,
Where?

as if
questioners DESERVED perfect answers handed to them on a plate.

I said no such thing, nor implied it.
The
best they can usually hope for are hints. If the hints are not
sufficient TOUGH. Don't blame those trying to help.

Why are you being so sensitive and defensive with me? What did I do to get
your attitude?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top