Tag Archives: Tomcat

An Android REST Client and Tomcat REST Webservice

Project Overview

This post will describe simple client-server communications between an Android app and a web service using REST techniques, particularly GET and POST. For this demo, we will be sending and receiving data for a simple Java class called Person, which includes a firstName, lastName and email address. The data stored in an instance of this class will be transmitted from our web service in JSON format.

NOTE: This post is a work in progress and will be updated and corrected, as time permits.

Prerequisites

This demo assumes that you have a version of Eclipse that can create a “Dynamic Web Project”, and that you have an instance of the Tomcat servlet container that you can control through Eclipse. This demo also assumes that you have the Android SDK, at least one Android Virtual Device (AVD), and have the Eclipse ADT plugin.

Another important requirement is that your Android device needs to be on the same network as your Tomcat server. The simplest way to do this would be to make sure you are running your emulator on the same computer that is running Tomcat.

About REST

REST – “Representational State Transfer” is a technique that makes use of standard web protocols for the implementation of a web service. A RESTful web service uses the standard HTTP GET PUT DELETE and POST actions to submit, retrieve or modify server-side data.

Commonly, in a REST web service, the standard HTTP actions are used as follows:

  • GET – retrieves or queries for data, usually using passed criteria
  • PUT – creates a new entry, record
  • DELETE – removes a resource
  • POST- updates a resource or creates a resource

The data that is transmitted uses standard MIME types, including images, video, text, html, XML and JSON.
Continue reading