title: Using POST to send data from Android to AppEngine Datastore
body: <p>Sorry if this is a simple question, but I just can't figure out what I'm supposed to do and I think I'm a bit out of my depth here.  I want to send data from an Android Application to my application running on Google App Engine.  From there the data must be written to the Datastore.  My data will mostly be in the form of objects, and I am working in Java.</p>
  
  <p>I came across the following question: <a href="https://stackoverflow.com/questions/5934939/how-can-i-connect-a-google-app-engine-application-with-my-android">how-can-i-connect-a-google-app-engine-application-with-my-android</a></p>
  
  <p>I think I understand what has to happen on the Android side.  I also understand how the doPost method works and what it's supposed to do.  But my problem is this, how can I now use PersistenceManagerFactory to write this data to my Datastore, or retrieve it?  I.e., how would the code inside the doPost look, if I wanted to use PersistenceManagerFactory there?</p>
  
  <p>Essentially, my mobile application must be able to do the same as my AppEngine application w.r.t. data retrieval/writing.</p>
  
  <p>Or should I forget about this method and do something different?</p>
  
  <p>Any pointer in the right direction will be greatly appreciated!</p>
  
  <p>Edit:</p>
  
  <p>I have started implementing Sam's solution as shown below.  However, something is still nor right.  here is what I am currently doing:</p>
  
  <p>Mapping my servlet in web.xml of my GAE-app:</p>
  
  <pre><code>&lt;servlet&gt;
      &lt;servlet-name&gt;this_servlet&lt;/servlet-name&gt;
  &lt;servlet-class&gt;*app-details*.server.JsonNews&lt;/servlet-class&gt;
  &lt;/servlet&gt;
  
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;this_servlet&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/my_app/my_app_place&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  </code></pre>
  
  <p>The implementation of the doPost() Method is the same as Sam's.</p>
  
  <p>In my Android-app:</p>
  
  <pre><code>DefaultHttpClient hc=new DefaultHttpClient();
  ResponseHandler &lt;String&gt; res=new BasicResponseHandler();
  HttpPost postMethod=new HttpPost("http://my_application.appspot.com/my_app/my_app_place");
  List&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;();  
  nameValuePairs.add(new BasicNameValuePair("value1", "Value my user entered"));  
  postMethod.setEntity(new UrlEncodedFormEntity(nameValuePairs));  
  String response=hc.execute(postMethod,res);
  </code></pre>
  
  <p>However, the hc.execute method fails, and provides me with the following message: Internal Server Error</p>
  
  <p>This leads me to believe that the error must be on the server side- but I am not sure where or why things are going wrong.  I copied Sam's code exactly, only changing the necessary things like "News".</p>