Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.

Posts: 100
Registered: ‎01-13-2011
My Device: Not Specified
Accepted Solution

post data to httpconnection http 302

I am tryind to send parameters via post to a httpconnection but always get http response code 302


this is my code:

HttpConnection conn = conn =  (HttpConnection) Connector.open(url, Connector.READ_WRITE, true);
URLEncodedPostData encoder = new URLEncodedPostData(URLEncodedPostData.DEFAULT_CHARSET, false);
conn.setRequestMethod( javax.microedition.io.HttpConnection.POST );
conn.setRequestProperty("Content-Length", String.valueOf(encoder.getBytes().length));
conn.setRequestProperty("Content-type", "application/x-www-form-urlencoded");
OutputStream oStream;
oStream = conn.openOutputStream();
oStream.write( encoder.getBytes() );

 What is courious is that if I use a BrowserField2 I can connect without problem using this code:


BrowserField browserField = new BrowserField();
final MainScreen screen = new MainScreen();
String postData = "param1=value&aparam2=" ...;
Hashtable header = new Hashtable();
header.put("Content-Length", "" + postData.length());
header.put("Content-Type", "application/x-www-form-urlencoded");
String url = "http://...";
browserField.requestContent(url, postData.getBytes(), header);
UiApplication.getUiApplication().invokeLater(new Runnable() {
	public void run() {
		UiApplication app = UiApplication.getUiApplication();


The problem is that I net get return params and I do not know how to get them using browserField



Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: post data to httpconnection http 302

302 means content moved, most likely you have to issue the request again for the new url (get it from the header).
the browserfield probably follows the redirect by itself.
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter