how to integrate servlet/jsp page in android application? - android

I want to store & retrieve the data from android web application to MySQL through jsp/servlet.
is it possible ? how : any other way to do this things.
thanks in advance.

Probably the easiest way is to use JSP/SERVLET as a middle layer, then send HTTP requests from your Android application to it.
To retrive data:
At JSP/SERVLET [Server] side code to:
connect to the database
run an SQL query, query may contain WHERE block depending on data from POST/GET
values
At Android [Client] side code:
use a HttpPost for sending the parameter value
convert response to string
parse the data and use it as you want.
Same way you can add new entries in database.
For reference look here or you can also use HTTPConnection.

Related

Android , Could we use Parse LocalDataStore for local Storage?

As we all know parse server being shutdown, but if i want to use parse local data store concept without any parse server interaction(without calling parse initialize(context,appkey,masterkey)) , then how could we achieve this?
Please suggest me if we can use it or not? If not , any best option apart from parse server for local data store?
Thanks in adavance!
You can't use Parse local datastore without parse backend. Objects do not get an objectid until the device is in contact with the Parse backend. Parse pinning is meant as a convenience addition to the backend; not as a replacement.
If you're now considering using ONLY parse local datastore, you should replace your solution with Core Data instead. Or consider setting up your own Parse server at i.e. Heroku.

Load remote String content into arraylist in Android?

On the server side I have a php script that connects to my mysql database and echo's string based on myurl.com/connection.php?id=22 where the 22 in the example obviously is the id for the string I want.
In my Android application I want to fill an arraylist with like 100 strings, but I am unsure how to do so, and what the best approach for doing it is.
As I understand I need to use asynctask to free the main thread from the process, and I have also looked at httpget although I am not sure if that is the only way of loading remote server content?
so from the my sql database the string values are returned ? right ?
the best way to do it is make the output from the server in json format and in your andriod app read the stream from the page and using json read fuctions and add the contents to your arralist using list . add() ; function...

server client database in android

i am very new to android and i would like to create an application that allows two clients to communicate with eachother through a server. One client saves data to a database ,also created in android and saved on the server, and the second one gets to see the database.
My problem is that i don't know how to create the server clients connection or how to store the data on the server.If anyone could help me with the code and some explanations about what sequence does what , and where the code must be written i would really appreciate it.Thanks.
P.S.
the database has 3 fields : id (primary key) , first name , last name.
There is many way to do this. But most of the people used the following two methods.
JSON Parsing
XML Parsing
You need to have a server written in some language e.g. PHP
From android, you can format the data you need to store in the server as a JSON message and send it via HTTP Post (preferred to be compressed) to the server where it should be stored in a back-end databse
See Android Post JSON for sample code

How to send an object of custom class from Android to Java Server?

I have created several classes in android client application corresponding to each database table (just like concept of Entity-Objects).
i want to retrieve data from database of the server to android client application and then assign that returned data set to objects of those created classes to further process the data and apply some logic.
I also want send data from android to server in the form of objects to process them on server or insert/update in the database.
(I can send the data to Servlet using HttpClient and HttpPost but don't know how to send objects and how to receive result set of database in the form of objects).
I'm new to client-server programming so my this approach might be wrong, if so then please correct me.
any sample code will be appreciated.
normally you would send some kind of String to the server which represents your Object. You could do that by generating JSON. There are nice libraries like GSON which can help you with that

External Database and Android application

I am creating an android application which records soccer scores.
I have an external mysql database created on my own host.
How do i retrieve the data from the database in order to display it in my application?
Thanks in advance!
You need to write a service hosted on your database using either php or some other language you are comfortable which exposes data as XML/JSON.
Android has HTTPURLConnection capability,using which you can query your service by passing the parameters. Your service queries database and consturcts data either as XML or JSON using libraries and returns to app.
Your app need to parse the response (if XML, using SAX/DOM or someother APIs, if JSON using Android in-buit json parser) and display. Here is an example on how to do.
If you also want to retrive the information to be used offline, you can create an empty database locally, and update it by passing SQL statements. This is not the most efficient way to do it, but it worked for me since I am not working with a huge db.
Otherwise, use HTTP connection connecting to your remote host and pass the result via JSON object.

Categories

Resources