dcsimg
Problem with data posted to a Server from MIDler
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Ravi_G
Posted On:   Wednesday, July 10, 2002 02:49 AM

I am using the following code to send the data from a MIDlet c = (HttpConnection)Connector.open("http://localhost/register.asp"); c.setRequestMethod(HttpConnection.POST); c.setRequestProperty("IF-Modified-Since", "20 Jan 2001 16:19:14 GMT"); c.setRequestProperty("User-Agent", "Profile/MIDP-1.0 Configuration/CLDC-1.0"); c.setRequestProperty("Content-Language", "en-CA"); c.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); os = c.openOutputStream(); String str = "name="+tfName.getString()+"&pwd="+tfPwd.getString(); byte postmsg[] = str.getB   More>>

I am using the following code to send the data from a MIDlet

			

c = (HttpConnection)Connector.open("http://localhost/register.asp");
c.setRequestMethod(HttpConnection.POST);
c.setRequestProperty("IF-Modified-Since", "20 Jan 2001 16:19:14 GMT");
c.setRequestProperty("User-Agent", "Profile/MIDP-1.0 Configuration/CLDC-1.0");
c.setRequestProperty("Content-Language", "en-CA");
c.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");

os = c.openOutputStream();
String str = "name="+tfName.getString()+"&pwd="+tfPwd.getString();
byte postmsg[] = str.getBytes();
for(int i=0;i
{
os.write(postmsg[i]);
}

os.close();

When I have entered name as 'ravi test name' at the server the name is retrieved as 'ravitestname'.
What is the solution for this. Can anybody please give me a solution. Thanks    <<Less

Re: Problem with data posted to a Server from MIDler

Posted By:   Liam_Quinn  
Posted On:   Wednesday, July 10, 2002 02:22 PM

For application/x-www-form-urlencoded, spaces need to be encoded as '+'. For details, see the relevant section of the HTML 4 specification.
About | Sitemap | Contact