Http

Put your problem here if it does not fit any of the other categories.

Http

Postby rohan » Sun Mar 23, 2008 4:41 pm

Hi all,

I have built a simple application . In that using http i have posted a msg to my server. Now in that server file i have sent the same msg to my application. Now instead of giving notification i want display that msg using TextView .
My server code is:
Syntax: [ Download ] [ Hide ]
Using php Syntax Highlighting
  1.                          <?
  2.  
  3.                                 echo "$_POST['data']"
  4.  
  5.                          ?>
Parsed in 0.055 seconds, using GeSHi 1.0.8.4

Using notification its workin fine..........but when i use TextView its giving me NullPointerException.
Plz reply , m new to android

Thanx,
Rohan
rohan
Developer
Developer
 
Posts: 34
Joined: Wed Mar 19, 2008 2:26 pm

Top

Postby kiran » Mon Mar 24, 2008 8:22 am

Hi,
where is the exception thrown. Have you initialize TextView properly?
:) smile it is the key that fits the lock of everybody's heart
User avatar
kiran
Experienced Developer
Experienced Developer
 
Posts: 78
Joined: Thu Nov 22, 2007 11:36 am
Location: India

Postby rohan » Mon Mar 24, 2008 8:34 am

Thanx kiran,
I actually dnt knw where to declare and use TextView . When I declare textview in "private class MyEventHandler implements EventHandler " method as "TextView tv;", and "tv.setText(msg);" in "void endData" but now i exactly dont knw where to put setContentView(tv); (when i put setContentView(tv) in notification method it gives me nullpointerexception). wht should i do?

Rohan .
rohan
Developer
Developer
 
Posts: 34
Joined: Wed Mar 19, 2008 2:26 pm

Postby kiran » Mon Mar 24, 2008 8:57 am

Hi,
One problem is that TextView has to be initialized like
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. TextView tv = new TextView(this);
Parsed in 0.032 seconds, using GeSHi 1.0.8.4

Try creating a global string in MyEventHandler that can be used to store the response. At the end of onCreate() add for example
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. TextView tv = new TextView(this);
  2.  
  3.           tv.setText(myEvH.str);
  4.  
  5.           setContentView(tv);
Parsed in 0.035 seconds, using GeSHi 1.0.8.4
The end data can be
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. public void endData() {
  2.  
  3.                str = new String(baf.toByteArray());
  4.  
  5.                }
Parsed in 0.035 seconds, using GeSHi 1.0.8.4
:) smile it is the key that fits the lock of everybody's heart
User avatar
kiran
Experienced Developer
Experienced Developer
 
Posts: 78
Joined: Thu Nov 22, 2007 11:36 am
Location: India

Postby rohan » Mon Mar 24, 2008 9:08 am

Thanx kiran,
I have tried wht you have suggested , but its still not working.
This is my code, can u plz edit and tel me where to write TextView and other stuff..... The main aim is to display msg using TextView .....



Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.          package com.project.HTTPTRY;
  2.  
  3.  
  4.  
  5. import java.io.ByteArrayInputStream;
  6.  
  7. import java.io.UnsupportedEncodingException;
  8.  
  9. import java.net.URLEncoder;
  10.  
  11. import java.util.HashMap;
  12.  
  13. import java.util.Iterator;
  14.  
  15. import java.util.Map;
  16.  
  17.  
  18.  
  19. import org.apache.http.util.ByteArrayBuffer;
  20.  
  21.  
  22.  
  23. import android.app.Activity;
  24.  
  25. import android.app.NotificationManager;
  26.  
  27. import android.net.http.EventHandler;
  28.  
  29. import android.net.http.Headers;
  30.  
  31. import android.net.http.RequestQueue;
  32.  
  33. import android.net.http.SslCertificate;
  34.  
  35. import android.os.Bundle;
  36.  
  37. import android.util.Log;
  38.  
  39. import android.widget.TextView;
  40.  
  41.  
  42.  
  43.  
  44.  
  45. public class httptry extends Activity {
  46.  
  47.  
  48.  
  49.      // ===========================================================
  50.  
  51.      // Fields
  52.  
  53.      // ===========================================================
  54.  
  55.      
  56.  
  57.      private final String DEBUG_TAG = "httpPostExample";
  58.  
  59.    
  60.  
  61.      // ===========================================================
  62.  
  63.      // 'Constructors'
  64.  
  65.      // ===========================================================
  66.  
  67.  
  68.  
  69.      @Override
  70.  
  71.      public void onCreate(Bundle icicle) {
  72.  
  73.           super.onCreate(icicle);
  74.  
  75.        
  76.  
  77.           /* Create a new HTTP-RequestQueue. */
  78.  
  79.           android.net.http.RequestQueue rQueue = new RequestQueue(this);
  80.  
  81.          
  82.  
  83.           /* Prepare the Post-Text we are going to send. */
  84.  
  85.           String POSTText = null;
  86.  
  87.           try {
  88.  
  89.                POSTText = "mydata=" + URLEncoder.encode("Mobiledumper rocks!!!", "UTF-8");
  90.  
  91.           } catch (UnsupportedEncodingException e) {
  92.  
  93.                return;
  94.  
  95.           }
  96.  
  97.           /* And put the encoded bytes into an BAIS,
  98.  
  99.            * where a function later can read bytes from. */
  100.  
  101.           byte[] POSTbytes = POSTText.getBytes();
  102.  
  103.           ByteArrayInputStream baos = new ByteArrayInputStream(POSTbytes);
  104.  
  105.          
  106.  
  107.           /* Create a header-hashmap */
  108.  
  109.           Map<String, String> headers = new HashMap<String, String>();
  110.  
  111.           /* and put the Default-Encoding for html-forms to it. */
  112.  
  113.           headers.put("Content-Type", "application/x-www-form-urlencoded");
  114.  
  115.          
  116.  
  117.           /* Create a new EventHandler defined above, to handle what gets returned. */
  118.  
  119.           MyEventHandler myEvH = new MyEventHandler(this);
  120.  
  121.  
  122.  
  123.           /* Now we call a php-file I prepared. It is exactly this:
  124.  
  125.            * <?php
  126.  
  127.            *        echo "POSTed data: '".$_POST['data']."'";
  128.  
  129.            * ?>*/
  130.  
  131.          // rQueue.queueRequest("http://www.anddev.org/postresponse.php", "POST",
  132.  
  133.          //          headers, myEvH, baos, POSTbytes.length,false);
  134.  
  135.           rQueue.queueRequest("http://www.mobiledumper.wsnw.net/httptry.php", "POST",
  136.  
  137.                   headers, myEvH, baos, POSTbytes.length,false);
  138.  
  139.  
  140.  
  141.           /* Wait until the request is complete.*/
  142.  
  143.           rQueue.waitUntilComplete();
  144.  
  145.          
  146.  
  147.      }
  148.  
  149.      
  150.  
  151.      // ===========================================================
  152.  
  153.      // Worker Class
  154.  
  155.      // ===========================================================
  156.  
  157.      
  158.  
  159.      private class MyEventHandler implements EventHandler {
  160.  
  161.           private static final int RANDOM_ID = 0x1337;
  162.  
  163.      //         public TextView tv;
  164.  
  165.           /** Will hold the data returned by the URLCall. */
  166.  
  167.           ByteArrayBuffer baf = new ByteArrayBuffer(20);
  168.  
  169.          
  170.  
  171.           /** Needed, as we want to show the results as Notifications. */
  172.  
  173.           private Activity myActivity;
  174.  
  175.  
  176.  
  177.           MyEventHandler(Activity activity) {
  178.  
  179.                this.myActivity = activity;  }
  180.  
  181.  
  182.  
  183.           public void data(byte[] bytes, int len) {
  184.  
  185.                baf.append(bytes, 0, len);  }
  186.  
  187.  
  188.  
  189.           public void endData() {
  190.  
  191.                String text = new String(baf.toByteArray());
  192.  
  193.                myShowNotificationAndLog("Data loaded: \n" + text);  
  194.  
  195.            
  196.  
  197.                }
  198.  
  199.          
  200.  
  201.           public void status(int arg0, int arg1, int arg2, String s) {
  202.  
  203.                myShowNotificationAndLog("status [" + s + "]");
  204.  
  205.                   }
  206.  
  207.  
  208.  
  209.           public void error(int i, String s) {
  210.  
  211.                this.myShowNotificationAndLog("error [" + s + "]");  
  212.  
  213.                   }
  214.  
  215.  
  216.  
  217.           public void handleSslErrorRequest(int arg0, String arg1, SslCertificate arg2) { }
  218.  
  219.           public void headers(Iterator arg0) { }
  220.  
  221.           public void headers(Headers arg0) { }
  222.  
  223.  
  224.  
  225.           private void myShowNotificationAndLog(String msg) {
  226.  
  227.                /* Print msg to LogCat and show Notification. */
  228.  
  229.                  
  230.  
  231.               Log.d(DEBUG_TAG, msg);
  232.  
  233.                NotificationManager nm = (NotificationManager) this.myActivity
  234.  
  235.                          .getSystemService(Activity.NOTIFICATION_SERVICE);
  236.  
  237.                nm.notifyWithText(RANDOM_ID, msg, NotificationManager.LENGTH_LONG, null);
  238.  
  239.                
  240.  
  241.                  
  242.  
  243.           }
  244.  
  245.          
  246.  
  247.      }
  248.  
  249.      
  250.  
  251. }
Parsed in 0.055 seconds, using GeSHi 1.0.8.4


plz reply

Rohan .
rohan
Developer
Developer
 
Posts: 34
Joined: Wed Mar 19, 2008 2:26 pm

Postby kiran » Mon Mar 24, 2008 9:30 am

Hi rohan,
Try this code...
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2.  package com.project.HTTPTRY;
  3.  
  4.  
  5.  
  6. import java.io.ByteArrayInputStream;
  7.  
  8. import java.io.UnsupportedEncodingException;
  9.  
  10. import java.net.URLEncoder;
  11.  
  12. import java.util.HashMap;
  13.  
  14. import java.util.Iterator;
  15.  
  16. import java.util.Map;
  17.  
  18.  
  19.  
  20. import org.apache.http.util.ByteArrayBuffer;
  21.  
  22.  
  23.  
  24. import android.app.Activity;
  25.  
  26. import android.app.NotificationManager;
  27.  
  28. import android.net.http.EventHandler;
  29.  
  30. import android.net.http.Headers;
  31.  
  32. import android.net.http.RequestQueue;
  33.  
  34. import android.net.http.SslCertificate;
  35.  
  36. import android.os.Bundle;
  37.  
  38. import android.util.Log;
  39.  
  40. import android.widget.TextView;
  41.  
  42.  
  43.  
  44.  
  45.  
  46. public class httptry extends Activity {
  47.  
  48.  
  49.  
  50. // ===========================================================
  51.  
  52. // Fields
  53.  
  54. // ===========================================================
  55.  
  56.  
  57.  
  58. private final String DEBUG_TAG = "httpPostExample";
  59.  
  60.  
  61.  
  62. // ===========================================================
  63.  
  64. // 'Constructors'
  65.  
  66. // ===========================================================
  67.  
  68.  
  69.  
  70. @Override
  71.  
  72. public void onCreate(Bundle icicle) {
  73.  
  74. super.onCreate(icicle);
  75.  
  76.  
  77.  
  78. /* Create a new HTTP-RequestQueue. */
  79.  
  80. android.net.http.RequestQueue rQueue = new RequestQueue(this);
  81.  
  82.  
  83.  
  84. /* Prepare the Post-Text we are going to send. */
  85.  
  86. String POSTText = null;
  87.  
  88. try {
  89.  
  90. POSTText = "mydata=" + URLEncoder.encode("Mobiledumper rocks!!!", "UTF-8");
  91.  
  92. } catch (UnsupportedEncodingException e) {
  93.  
  94. return;
  95.  
  96. }
  97.  
  98. /* And put the encoded bytes into an BAIS,
  99.  
  100. * where a function later can read bytes from. */
  101.  
  102. byte[] POSTbytes = POSTText.getBytes();
  103.  
  104. ByteArrayInputStream baos = new ByteArrayInputStream(POSTbytes);
  105.  
  106.  
  107.  
  108. /* Create a header-hashmap */
  109.  
  110. Map<String, String> headers = new HashMap<String, String>();
  111.  
  112. /* and put the Default-Encoding for html-forms to it. */
  113.  
  114. headers.put("Content-Type", "application/x-www-form-urlencoded");
  115.  
  116.  
  117.  
  118. /* Create a new EventHandler defined above, to handle what gets returned. */
  119.  
  120. MyEventHandler myEvH = new MyEventHandler(this);
  121.  
  122.  
  123.  
  124. /* Now we call a php-file I prepared. It is exactly this:
  125.  
  126. * <?php
  127.  
  128. * echo "POSTed data: '".$_POST['data']."'";
  129.  
  130. * ?>*/
  131.  
  132. // rQueue.queueRequest("http://www.anddev.org/postresponse.php", "POST",
  133.  
  134. // headers, myEvH, baos, POSTbytes.length,false);
  135.  
  136. rQueue.queueRequest("http://www.mobiledumper.wsnw.net/httptry.php", "POST",
  137.  
  138. headers, myEvH, baos, POSTbytes.length,false);
  139.  
  140.  
  141.  
  142. /* Wait until the request is complete.*/
  143.  
  144. rQueue.waitUntilComplete();
  145.  
  146.  
  147.  
  148. TextView tv = new TextView(this);
  149.  
  150. tv.setText(myEvH.str);
  151.  
  152. setContentView(tv);
  153.  
  154.  
  155.  
  156. }
  157.  
  158.  
  159.  
  160. // ===========================================================
  161.  
  162. // Worker Class
  163.  
  164. // ===========================================================
  165.  
  166.  
  167.  
  168. private class MyEventHandler implements EventHandler {
  169.  
  170. private static final int RANDOM_ID = 0x1337;
  171.  
  172.  
  173.  
  174. String str;
  175.  
  176.  
  177.  
  178. // public TextView tv;
  179.  
  180. /** Will hold the data returned by the URLCall. */
  181.  
  182. ByteArrayBuffer baf = new ByteArrayBuffer(20);
  183.  
  184.  
  185.  
  186. /** Needed, as we want to show the results as Notifications. */
  187.  
  188. private Activity myActivity;
  189.  
  190.  
  191.  
  192. MyEventHandler(Activity activity) {
  193.  
  194. this.myActivity = activity; }
  195.  
  196.  
  197.  
  198. public void data(byte[] bytes, int len) {
  199.  
  200. baf.append(bytes, 0, len); }
  201.  
  202.  
  203.  
  204. public void endData() {
  205.  
  206. String text = new String(baf.toByteArray());
  207.  
  208. //myShowNotificationAndLog("Data loaded: \n" + text);
  209.  
  210. str = new String(text);
  211.  
  212.  
  213.  
  214. }
  215.  
  216.  
  217.  
  218. public void status(int arg0, int arg1, int arg2, String s) {
  219.  
  220. myShowNotificationAndLog("status [" + s + "]");
  221.  
  222. }
  223.  
  224.  
  225.  
  226. public void error(int i, String s) {
  227.  
  228. this.myShowNotificationAndLog("error [" + s + "]");
  229.  
  230. }
  231.  
  232.  
  233.  
  234. public void handleSslErrorRequest(int arg0, String arg1, SslCertificate arg2) { }
  235.  
  236. public void headers(Iterator arg0) { }
  237.  
  238. public void headers(Headers arg0) { }
  239.  
  240.  
  241.  
  242. private void myShowNotificationAndLog(String msg) {
  243.  
  244. /* Print msg to LogCat and show Notification. */
  245.  
  246.  
  247.  
  248. Log.d(DEBUG_TAG, msg);
  249.  
  250. NotificationManager nm = (NotificationManager) this.myActivity
  251.  
  252. .getSystemService(Activity.NOTIFICATION_SERVICE);
  253.  
  254. nm.notifyWithText(RANDOM_ID, msg, NotificationManager.LENGTH_LONG, null);
  255.  
  256.  
  257.  
  258.  
  259.  
  260. }
  261.  
  262.  
  263.  
  264. }
  265.  
  266.  
  267.  
  268. }
  269.  
  270.  
Parsed in 0.051 seconds, using GeSHi 1.0.8.4
:) smile it is the key that fits the lock of everybody's heart
User avatar
kiran
Experienced Developer
Experienced Developer
 
Posts: 78
Joined: Thu Nov 22, 2007 11:36 am
Location: India

Top

Postby rohan » Mon Mar 24, 2008 9:38 am

thanx kiran,
Its working............Is is necessary to write the notification method?
thanx a lot :D

Rohan .
rohan
Developer
Developer
 
Posts: 34
Joined: Wed Mar 19, 2008 2:26 pm

Postby kiran » Mon Mar 24, 2008 9:48 am

welcome, myNotificationandLog() can be removed....
:) smile it is the key that fits the lock of everybody's heart
User avatar
kiran
Experienced Developer
Experienced Developer
 
Posts: 78
Joined: Thu Nov 22, 2007 11:36 am
Location: India

Postby rohan » Mon Mar 24, 2008 12:59 pm

hi kiran,
I have created a file in which user has to enter his username and password ,after submitting the data my app connects to server and sends the same data to the app. See this code,(its not working ,its givin me nullpointerexception). plz help

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. package com.project.HTTPTRY;
  2.  
  3.  
  4.  
  5. import java.io.ByteArrayInputStream;
  6.  
  7. import java.io.UnsupportedEncodingException;
  8.  
  9. import java.net.URLEncoder;
  10.  
  11. import java.util.HashMap;
  12.  
  13. import java.util.Iterator;
  14.  
  15. import java.util.Map;
  16.  
  17. import java.lang.String;
  18.  
  19.  
  20.  
  21. import org.apache.http.util.ByteArrayBuffer;
  22.  
  23.  
  24.  
  25. import android.app.Activity;
  26.  
  27.  
  28.  
  29. import android.net.http.EventHandler;
  30.  
  31. import android.net.http.Headers;
  32.  
  33. import android.net.http.RequestQueue;
  34.  
  35. import android.net.http.SslCertificate;
  36.  
  37. import android.os.Bundle;
  38.  
  39.  
  40.  
  41. import android.view.View;
  42.  
  43. import android.view.View.OnClickListener;
  44.  
  45. import android.widget.Button;
  46.  
  47. import android.widget.EditText;
  48.  
  49. import android.widget.TextView;
  50.  
  51.  
  52.  
  53.  
  54.  
  55. public class httptry extends Activity {
  56.  
  57.  
  58.  
  59. // ===========================================================
  60.  
  61. // Fields
  62.  
  63. // ===========================================================
  64.  
  65. private EditText logE,passE;
  66.  
  67. private Button logB;
  68.  
  69. private final String DEBUG_TAG = "httpPostExample";
  70.  
  71. MyEventHandler myEvH = new MyEventHandler(this);
  72.  
  73. android.net.http.RequestQueue rQueue = new RequestQueue(this);
  74.  
  75. TextView tv = new TextView(this);
  76.  
  77. String POSTText = null;
  78.  
  79. StringBuilder strB=new StringBuilder();
  80.  
  81. // ===========================================================
  82.  
  83. // 'Constructors'
  84.  
  85. // ===========================================================
  86.  
  87.  
  88.  
  89. @Override
  90.  
  91. public void onCreate(Bundle icicle) {
  92.  
  93. super.onCreate(icicle);
  94.  
  95. setContentView(R.layout.main);
  96.  
  97. logB = (Button) findViewById(R.id.logButton);
  98.  
  99. logB.setOnClickListener(clickListener);
  100.  
  101.  
  102.  
  103. }
  104.  
  105.  
  106.  
  107. private OnClickListener clickListener = new OnClickListener() {
  108.  
  109.  
  110.  
  111. public void onClick(View v) {
  112.  
  113.  
  114.  
  115.  
  116.  
  117. logE=(EditText)findViewById(R.id.logEdit);
  118.  
  119. passE=(EditText)findViewById(R.id.passEdit);
  120.  
  121. try {
  122.  
  123.  
  124.  
  125. strB.append("UserId=");
  126.  
  127. strB.append(URLEncoder.encode(logE.getText().toString(),"UTF-8"));
  128.  
  129. strB.append("&");
  130.  
  131. strB.append("PassWd=");
  132.  
  133. strB.append(URLEncoder.encode(passE.getText().toString(),"UTF-8"));
  134.  
  135. POSTText=strB.toString();
  136.  
  137. } catch (UnsupportedEncodingException e) {
  138.  
  139. return;
  140.  
  141. }
  142.  
  143. /* And put the encoded bytes into an BAIS,
  144.  
  145. * where a function later can read bytes from. */
  146.  
  147. byte[] POSTbytes = POSTText.getBytes();
  148.  
  149. ByteArrayInputStream baos = new ByteArrayInputStream(POSTbytes);
  150.  
  151.  
  152.  
  153. /* Create a header-hashmap */
  154.  
  155. Map<String, String> headers = new HashMap<String, String>();
  156.  
  157. /* and put the Default-Encoding for html-forms to it. */
  158.  
  159. headers.put("Content-Type", "application/x-www-form-urlencoded");
  160.  
  161.  
  162.  
  163. /* Create a new EventHandler defined above, to handle what gets returned. */
  164.  
  165. // MyEventHandler myEvH = new MyEventHandler(this);
  166.  
  167.  
  168.  
  169. /* Now we call a php-file I prepared. It is exactly this:
  170.  
  171. * <?php
  172.  
  173. * echo "POSTed data: '".$_POST['data']."'";
  174.  
  175. * ?>*/
  176.  
  177. // rQueue.queueRequest("http://www.anddev.org/postresponse.php", "POST",
  178.  
  179. // headers, myEvH, baos, POSTbytes.length,false);
  180.  
  181. rQueue.queueRequest("http://www.mobiledumper.wsnw.net/httptry.php", "POST",
  182.  
  183. headers, myEvH, baos, POSTbytes.length,false);
  184.  
  185.  
  186.  
  187. /* Wait until the request is complete.*/
  188.  
  189. rQueue.waitUntilComplete();
  190.  
  191.  
  192.  
  193. tv.setText(myEvH.str);
  194.  
  195. setContentView(tv);
  196.  
  197. }
  198.  
  199. };
  200.  
  201. // ===========================================================
  202.  
  203. // Worker Class
  204.  
  205. // ===========================================================
  206.  
  207.  
  208.  
  209. private class MyEventHandler implements EventHandler {
  210.  
  211. private static final int RANDOM_ID = 0x1337;
  212.  
  213. String str;
  214.  
  215. /** Will hold the data returned by the URLCall. */
  216.  
  217. ByteArrayBuffer baf = new ByteArrayBuffer(20);
  218.  
  219.  
  220.  
  221. /** Needed, as we want to show the results as Notifications. */
  222.  
  223. private Activity myActivity;
  224.  
  225.  
  226.  
  227. MyEventHandler(Activity activity) {
  228.  
  229. this.myActivity = activity; }
  230.  
  231.  
  232.  
  233. public void data(byte[] bytes, int len) {
  234.  
  235. baf.append(bytes, 0, len); }
  236.  
  237.  
  238.  
  239. public void endData() {
  240.  
  241. String text = new String(baf.toByteArray());
  242.  
  243. // myShowNotificationAndLog("Data loaded: \n" + text);
  244.  
  245. str = new String(text);
  246.  
  247.  
  248.  
  249. }
  250.  
  251.  
  252.  
  253. public void status(int arg0, int arg1, int arg2, String s) {
  254.  
  255. // myShowNotificationAndLog("status [" + s + "]");
  256.  
  257. }
  258.  
  259.  
  260.  
  261. public void error(int i, String s) {
  262.  
  263. // this.myShowNotificationAndLog("error [" + s + "]");
  264.  
  265. }
  266.  
  267.  
  268.  
  269. public void handleSslErrorRequest(int arg0, String arg1, SslCertificate arg2) { }
  270.  
  271. public void headers(Iterator arg0) { }
  272.  
  273. public void headers(Headers arg0) { }
  274.  
  275.  
  276.  
  277.  
  278.  
  279.  
  280.  
  281. }
  282.  
  283.  
  284.  
  285. }
Parsed in 0.053 seconds, using GeSHi 1.0.8.4



Rohan .
rohan
Developer
Developer
 
Posts: 34
Joined: Wed Mar 19, 2008 2:26 pm

Postby kiran » Mon Mar 24, 2008 1:12 pm

Hi rohan,
The problem seems to be with your .php file. can it handle variables UserId and PassWd. can you post your php file?
Regards,
Kiran
:) smile it is the key that fits the lock of everybody's heart
User avatar
kiran
Experienced Developer
Experienced Developer
 
Posts: 78
Joined: Thu Nov 22, 2007 11:36 am
Location: India

Postby rohan » Mon Mar 24, 2008 1:14 pm

kiran,

<?php
echo "POSTed data: '".$_POST['data']."'";
?>

its not handling nething, wht should i do?

Rohan
rohan
Developer
Developer
 
Posts: 34
Joined: Wed Mar 19, 2008 2:26 pm

Postby kiran » Mon Mar 24, 2008 1:21 pm

hi rohan,
with this php. the response you get will be the data you are passing in the variable 'data'. The reason you are not getting any response is because you are passing UserId and PassWd and no data. I think the problem is with your php file
Regards,
Kiran.
:) smile it is the key that fits the lock of everybody's heart
User avatar
kiran
Experienced Developer
Experienced Developer
 
Posts: 78
Joined: Thu Nov 22, 2007 11:36 am
Location: India

Postby rohan » Mon Mar 24, 2008 1:24 pm

thanx kiran,
but i m combining my data as "userid=rohan&passwd=rohan" and i m sending this whole string to php file, i think it shld reply me the same as data.
rohan
Developer
Developer
 
Posts: 34
Joined: Wed Mar 19, 2008 2:26 pm

Postby kiran » Mon Mar 24, 2008 1:31 pm

hi rohan,
dont know but using
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. POSTText = "mydata=Hello";
Parsed in 0.035 seconds, using GeSHi 1.0.8.4
with your url returns the correct response.
:) smile it is the key that fits the lock of everybody's heart
User avatar
kiran
Experienced Developer
Experienced Developer
 
Posts: 78
Joined: Thu Nov 22, 2007 11:36 am
Location: India

Postby rohan » Mon Mar 24, 2008 1:41 pm

hi kiran,
i have used "myData=hello" but it still giving sme nullpointerexception. I think bcoz i have written sme things in OnClick method it gives me error...wht do u say?
rohan
Developer
Developer
 
Posts: 34
Joined: Wed Mar 19, 2008 2:26 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Google [Bot] and 16 guests