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 Parameters GET after a connection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "Parameters GET after a connection" Watch "Parameters GET after a connection" New topic

Parameters GET after a connection

Ould Nadif
Ranch Hand

Joined: Jan 21, 2004
Posts: 184
Hi all,

I would like send a connection to my server with 3 paramaters using httpConnection GET.

For example¶m2=2¶3=3

I know that : conn = ( HttpConnection ) "¶m2=2¶3=3") works fine.

My question is:

Is it possible to have the same result using the following :

First of all I send this connection
conn = ( HttpConnection ) "

If the connection works is OK I send this:

os = conn.openOutputStream();

Thanks you in advance


We are ones that build the world, thus build it well.
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

Yes, but I think you will want to look at the setRequestProperty(String key, String value) method. Remember that even though you are on J2ME, the methods that you need to set content, heard, etc information in your Request object is available.


Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
Ould Nadif
Ranch Hand

Joined: Jan 21, 2004
Posts: 184

I couldn't recuperate the values of parameters side server.
The value worth null side server.
param1=null etc...
conn = ( HttpConnection ) "",Connector.READ_WRITE );

Netherless, If I use http://¶m2=2¶m3=3
in the browser then I recuperated the value of param1, param2 etc.. side Servlet, therefore my servlet works fine.

I have doubts if setRequestProperty send the parametres of the connection.

Thank you for your help.

Eduardo Marques
Ranch Hand

Joined: Feb 19, 2005
Posts: 231
I think several things are being mixed up here:

- If you want to set a query string with GET you should specify it in the URL . For example:
HttpConnection c = (HttpConnection)"");

- To use the connection's ouput stream the request type has to be set to POST.
OutputStream os = c.openOutputStream();

- setRequestProperty() methods sets information in the HTTP protocol request header - this is not very good to pass data parameters and may
be misunderstood by the HTTP server.

Also, depending on which method you use the interface at the other end is different.

Eduardo Marques
Get ready for your SCMAD certification at - See what all the buzz is about ...
Ould Nadif
Ranch Hand

Joined: Jan 21, 2004
Posts: 184
Thank you for your reply.
I agree with you.Finally I replace GET by POST.I seems it works better.


I agree. Here's the link:
subject: Parameters GET after a connection
It's not a secret anymore!