0

probably you all ask why I tagged Java, jsp, Objective-c, xCode... in that question, actually that is my question, how efficiently combines them all? I have two servlets running in localhost, one handle the "Clients" and the other handle "Professionals". In the two servlets i can make a registration and ask for queries from the database, I'm using SQL database. I would like to write an iOS 6 application using this servlets, and make the same things, so how can I write an application that will use the exist code without duplication of an exist code? All of the logic exists in the servlets, registration, asking for prices, write comments about professionals... How can I write an application that will use this website?

I will give three examples:

  1. In the registration of a client or a professional, he enters his phone number, so in the application i don't need to enter the phone number; I suppose that there is a function that can bring the phone number. So all we need is to insert the phone number in the specific text field.
  2. In the client site I have an order: for a professional by the client, so, in the application, I would like that the place of the client will be send to the professional, using his current GPS position.

  3. When a client order a professional, I would want that the application will send a push notification using apns (Apple Push Notification), for "waking up" the professional application and upload the exist page that manage the orders.

I guess this question came before and solved by experienced programmers. So maybe there is a simple way not to duplicate the exist code that I have in the servlets. Only to use it. Can you refer me for a starting point? References? Guides?

Matan Touti
  • 191
  • 2
  • 14
  • I doubt iOS lets you grab the user's phone number through an API, this sounds like a privacy issue. – millimoose Jan 16 '13 at 18:07
  • Also you seem to be a little confused about how push notifications work. You definitely don't upload a page with them, you can send at most 256 bytes of data (i.e. a message, and at best a link to said page for the app to open.) – millimoose Jan 16 '13 at 18:10
  • i mean that the push notification will send to the iphone only to "wake up" the application. and after the application woke up, it will receive from the database the information. the push notification will not contain the hole data. about privacy issues yes its sounds very logical, i found in: http://stackoverflow.com/questions/6055091/is-it-possible-to-get-iphones-phone-number-programmatically-in-2011 – Matan Touti Jan 16 '13 at 18:24

1 Answers1

2

The typical way for mobile applications to interact with servers is through a webservice, usually a REST (or alike) one.

Servlets that output HTML are useless in this scenario, and you should avoid them because you are transfering lots of information that isn't needed. I'm talking about all the HTML and CSS that is passing through the network. Reducing network traffic is a top priority in mobile applications as you might imagine.

Consider developing a REST webservice, or at least a servlet that outputs and receives meaningful JSON objects. These are just raw data and not filled with useless formatting related traffic. You could reuse some of your code to build and return these objects.

I hope I understood your scenario.

miguelcobain
  • 4,734
  • 4
  • 32
  • 45
  • A "servlet that outputs and receives meaninful JSON objects" is basically a web service really. (Just not one using a standard protocol or methodology.) – millimoose Jan 16 '13 at 18:11