Can't decide how correctly to use backend? - java

In my project need to create the following architecture:
Front-End application is a web site resource that will combine HTML+React technologies.
Back-End is a java application that will be connected to Mongo DB to operate with data.
Now, in the middleware should be placed Node.js. And after reading a lot of info on the internet, I have now some confusions regarding this.
As I understand Frond-End will be routed to node.js (and now the question is it Express.js-- the same thing or it's different) which is also connected to Mongo Db and Java application(this is doing all logic).
Can someone explain me should use express.js with the integration of node.js in order to route to java server application?

If you want to use a middleware. Nodejs can help you do that in a lot of ways, you can use express.js so that you won't have to do more request/response parsing work. And when you want to connect to your java server using nodejs, you can also integrate that by calling the java server API endpoint by using some http library like axios then you can directly communicate to java server app to directly communicate to the backend mongodb.
But your Front-End application can also directly communicate through your backend java by creating a REST API. And store all your business logic in the java REST API.

Related

Spring Rest API Confusion

I am exploring the possibility of using a RESTful API as the backend for an Android application.
I previously have simply been using socket programming to have my clients connect to server application but since I intend to develop a web application (with the admin functionalities for the android app) I figured this may be a good option.
My backend will be required to pull data from a nosql database and run a machine learning algorithm periodically on the data. The android app will, amongst other things, query the results of the computations and provide additional information to the algorithm.
Is it possible for me to use Spring to expose some of the application functionality through a REST API while still having other functions and tasks running in the background? Basically, can I design an application that will query multiple web services and perform various scheduled computations and query and expose only some of those functions through an API ?
Am I approaching this completely the wrong way?
Your approach sounds fine to me. Your REST API could just call internal backend methods as needed and return their output as JSON or XML formatted data.
I recommend you, if you haven't already looked at them, to go through the Spring "Getting Started" guides for building a RESTful web service and scheduling tasks.
On the Android side I'd recommend you to look into Retrofit.

Communication between JSP/Servlet and PHP pages?

I am working on a web based Java application(on localhost) and I want to send email using a PHP script which is hosted on a free web hosting site and also return to my java app.
Like this ->
Java(localhost)---->PHP(send mail)---->Java(localhost)
Few questions regarding this?
How to do this?
What about the session stored by the java app? Will the PHP script
read or interpret java's session?
My suggestion is Implement an web service (in REST or SOAP Architecture) with php
then in java code call your web service and Implement an acknowledgement response for
successful or failure mail sending operation in your php!
SOA (Service Oriented Architecture) could be one of best approach for communication between
different platforms.
if you use php only because of ease of sending mail it would be fine to know that java also
have JavaMail API that can be used for mailing application very easily
I hope it be beneficial
Regards

Connecting Google App Engine with Javascript client

I have a diagram editor application (client), which is written in javascript. I need to take the model of the diagrams (can be transformed to text), and synchronise it with my GAE Java application which will be my backend. The application will then store this model on cloud, or send it to other clients. (as a result many people work on same diagrams)
This is a totally new field to me, and even though I completed some of the tutorials google provides, and gone through documentation, I am not sure how the connection will be done (tutorials used JSP).
What is the most straight- forward approach into connecting a Java
application (GAE) with a JS client ?
p.s: I have read about ajax, but I dont know if its the right solution for this, or if there is a better one.
What is the most straight- forward approach into connecting a Java
application (GAE) with a JS client ?
Through an API built on HTTP. Your JAVA web app can expose certain endpoints. You can then use Javascript to make http requests, (through AJAX) to your java web api). This is currently the defacto way of communicating from front end with javascript to any backend service.
There will be some trickiness to supporting real time collaboration between clients.
Additionally, there has been increasing support for websockets, which allows you to open a persistant connection between your client and your server, i don't know if java on GAE supports it though...

Php - middleware

I am developing a php based application which has java as middleware for web services. Is there any frameowork/middleware available in php stack which allows me to write services in php and also hosted on php based app server, lets say Zend?
Thanks
Typically I'd expect the middleware to be the webservices - are you consuming or providing webservices using PHP?
Not that it makes much difference, PHP supports both.
You can roll your own solution, or use PHP Soap, the nuSoap PHP lib and xmlrpc. There's also the php/java bridge which implements a socket based abstraction for both ends (but obviously this is not strictly a web service).

Help regarding What DBMS to use for interaction between android phone, server and database?

I am looking for some guideance in terms of what database to use server(using servlets) side of my android application.
Further down the line i will setup a website that will need to access the information from with the database.
At the moment from what i know i can use hibernate for object mapping to RDBMS or i can use JDBC for interaction with a MySql Database.
Do you guys have any best practices for using either the above or a different system for interaction between servlet and database?
If you are looking to get started quickly, you could use AppInventor, but if you want to build a backend yourself I suggest Ruby on Rails(get ubuntu if you don't have it!). Its easy to learn, easy to install, and very user-friendly.
The server and database will be handled by the Ruby on Rails framework.
Android application just acts as a client that makes request and accepts response from a Server. Server could be written using Servelets / JSP, ASP or PHP. As far as I know it doesn't matter to android client which database server is used at the server side as far as client is getting the response from the server.

Categories