how to communicate from javascript to java application - java

I am storing data in a cloud in some format. This cloud is accessible through https URL. There are java and java script API's to communicate with cloud. I want to provide basic CRUD functionality. I have a textarea in which I am receiving input from the user. I have a java library for parsing the SQL queries. How do I communicate from javascript in my HTML page to java application where it performs computation on data on cloud and communicates with cloud.
I am a newbie at web development. I appreciate any help!!

Google ajax.......
With Ajax, web applications can send data to, and retrieve data from, a server asynchronously (in the background) without interfering with the display and behavior of the existing page. Data can be retrieved using the XMLHttpRequest object. Despite the name, the use of XML is not required (JSON is often used instead), and the requests do not need to be asynchronous.
http://en.wikipedia.org/wiki/Ajax_(programming)
http://howtodoinjava.com/2013/06/21/complete-ajax-tutorial/
https://netbeans.org/kb/docs/web/ajax-quickstart.html
http://javapapers.com/ajax/getting-started-with-ajax-using-java/

Related

I want to exchange data between my Android application and my web site

Android web view is not what i looking for.Android interface is completely different from the web view.Do I want to make my Web and Android app to use REST web services? I am designing my web using springMVC.
What data are you expecting to exchange from and to the website? Does this mean you will be adding, deleting, updating the data or just simply retrieving
Regardless I would look at Json data if your website is capable of providing that. If Yes, I would recommend using retrofit to download the data onto your application and use it however you like. Retrofit is also capable of working in conjunction with CRUD methods as well.

how to communicate android application to mysql database through JSP and Servlet

I am creating an android application and I want that when user fill up the registration form in my android application then that data should be saved in remote MySQL database.But i want JSP and Servlet for this as middle level.
I searched a lot on internet but every tutorial shown on internet are using PHP. I don't want to use PHP at server side.
So is there any tutorial or resource for saving android application data to remote MySQL database using JSP and Servlet.
You usually call RESTful services from the Android App. The RESTful services can be written in any language of your choice. Your Android client is one which is communicating with the REST Backend. If you are using ButtonView and on the click of it some update or retrieval are supposed to be performed then REST based services are best.
I would recommend this approach.
Look at the way servlet is deployed from the below blog :
http://hmkcode.com/java-servlet-send-receive-json-using-jquery-ajax/
Hit the servlet URL in a browser.If u get the JSON response, the same call can be leveraged from the mobile client building the URLconnection and rendered in the app using some Parser at Mobile end.
Hope this meets the requirement.

Building a server side api that can simultaneously transfer data between mobile and web applications

I am creating a web application that uses ruby on rails for the server side with mysql, and I want to build an api that will allow a unified interchange between both java for android and objective-C for ios. How should I get started?
Looks like you have to creates a server side REST apis which will be consumed by the mobile apps built in android or iOS. APIs are always independent of client side technology that is it can respond to any client. Apis can return data in xml or json format.
Using ruby on rails it is very easy to build REST apis with very fast development. Rails provide very easy ways to return output as json or xml, means you don't need to write separate code for both.
For that in controller you need to add following line on top
respond_to :html, :json, :xml
And in method definition you can write
respond_with(users)
It will return specific format based on request url like .json or .xml in URL.

How do I manage HTTP communication between a Apache web server and Google App Engine?

I am currently developing a web application in the Google App Engine using Java and PrimeFaces. I have to access a remote MySQL server, my clients website's database. This website contains all the data which my application requires.
I have searched the web and found out that there is no direct method to access any database with Google app engine.
So I decided to create a PHP script on the web server which will accept SQL queries as HTTP requests on behalf of the MySQL server and send the returned data as a HTTP response. (Encrypted of course!)
How can I send a large result set over HTTP from a PHP web server to Google App Engine?
The problem I am facing here is that, although I can manage to get a HTTP request via GET in PHP. How do I send them back, just flushing wont do, and how do I redirect them back to the Google App Engine's my application specifically.
Thanks!
You can use the UrlFetch api to send requests from appengine to your MySQL server. You'll get a response, and can parse it directly in appengine.
You can set up servlets in your appengine app that your MySQL server can trigger with requests. Your MySQL server can send a request (your php GET function) to yourapp.appspot.com/servletpath, which will start your appengine servlet. Appengine can return a response from there.
If dataset is too big to be transferred in one lump then just split it over several requests by adding a range limit to your query. Also make use of task queue to split this job over several tasks. It is common practice on appengine to split everything what takes too long/too big into several tasks. Divide and conquer.

Communication between a desktop app and a web app?

I'm interested in having a desktop application send messages to a web app. Specifically, the desktop app, written in Java, needs to send messages to a Javascript function that will be running in a browser. The messages only need to be sent one way. Also, both programs will be running on the same local machine. I can set up a local development server if necessary.
I'm new to networking and web development and I have no idea how to approach this problem. Can anyone offer any suggestions?
I think the appropriate way to do that (if not the only way) would be to go through a server both apps talks to
The enterprise architecture way I recommend you do is:
Put the common information into a webservice.
The website sends information, possibly via ajax or by navigating to a different URL or doing a form POST to the webservice.
The desktop app will start up and will subscribe to the webservice. The webservice will notify the desktop app once it has an update. (note that the desktop app, might need to poll for updates).
That approach is how services such as flikr, twitter etc use.
The light weight (ie smaller architecture) way of hacking this is to make your website have an RSS feed that your desktop app subscribes to. The desktop app gets updated via the RSS feed.
That approach is how services such as news websites will send updates to readers. See google reader as an example RSS client. RSS has an adavantage of supporting generic rss consumers like MS outlook or google reader from the start, where as webservices are likely to be more flexible and cleaner in the long run.
why does the desktop app need to talk to javascript? What is it you are actually trying to do? Send or receive data to or from a database? Run some business logic on the web app? These things are typically done from a desktop app to a website using soap or rest.
is the browser embedded somehow in the desktop app? Or could is it just running as a separate process? It seems like audio processing should really run in the desktop app.
However, assuming that the browser is running as a separate app, you should be able to send messages to the browser through the query string. The desktop app could fire up the browser, point it to a url and pass some parameters to it. THen javascript can process those parameters. Google whether jquery can process query string parameters.
Embed a simple container like jetty then use Jersey or a Simple Servlet

Categories

Resources