Answer the question
In order to leave comments, you need to log in
How are UI on JS and Java EE server-side friendly?
Hello.
Tell me, what is currently the best practice for creating interaction between a UI written in JS and a server written in Java?
For example, to connect Flex (aka ActionScript) and Java, there are 2 main frameworks:
1. BlazeDS.
2.GraniteDS.
Which allow to exchange DTO among themselves, through "raising" RemoteObject. Inside, as I understand it, serialization / deserialization takes place and these DTOs are transmitted through their channels (eg AMFChannel).
What techniques or frameworks are used for UI written in JS?
As I see it, there are several options:
1. Calling java code from JS: www.sitepoint.com/connect-java-to-javascript-with-...
2. Writing Rest API and calling services from there. (I personally do not like it, I believe that there will be serious problems with performance, and it will look somehow crooked)
3. Some kind of framework that exchanges DTOs between JS and Java? If such exists.
4. Have JSF\JSP pages that contain JS code inserts. (but this is straight out of a cannon)
For a visual example: for example, there is a task in which one of the modules must use the d3js library ( d3js.org ), and receive data from a server written in Java (for example, using Spring )
Answer the question
In order to leave comments, you need to log in
2. Writing a Rest API
This approach is now mainstream in web development. The performance is high, the mechanism is universal and supported by almost all languages/frameworks. For example: it was possible to switch from the built-in mechanisms for exchanging data with the GWT server, to transfer the same data using REST - with the same data volumes, the response time was significantly reduced.
In addition to performance, usability is also on top - in most cases, the code is concise and clear. Server calls can be made from almost anywhere in your JS client. The main thing is not to forget about asynchrony, and build logic with this in mind: process code that depends on the results of the request in callbacks passed to the REST call.
3) GWT, for example. You write code in java and it compiles to js. So many java classes can be used (DTOs even more so). However, the technology is quite peculiar, it is not always suitable. And the GWT compiler does not support everything from JavaCore and is not friendly (yet) with Java8.
PS from similar there is also Vaadin
2) Rest API. Plus Web Socket for sending a message from the server to the client, this will give more options for client interaction with the server, and not just work in request-response mode, as Rest implies
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question