0

My company currently has a Java project that allows us to run jobs to process data. The current project has a web interface, but its rather old, and most of the web interface is implemented through Java Servlets by printing HTML out to the web browser.

We want to instead create a REST API using the same core process, and replace the web interface with a different implementation in the future. Then eventually, we may have customers use the REST API.

My question is this: I understand NodeJS is pretty powerful, and from what I've read, makes the most sense when developing a REST API with the JavaScript and JSON integration. Should I attempt to create the REST API with Java, and if so, should I use JavaEE and Glass Fish, or should I have the API be built with NodeJS, then have the NodeJS server call the core Java service to process the requests?

I understand I may be introducing unnecessary complexity, however the project is rather large, and it won't be feasible to port the project over to NodeJS. I don't have experience with REST API creation (or SOAP), so this is new territory for me.

Thanks for the help, Colby

1
  • I would like to do the second, Java for the core application and Node JS used for the API. If I'm not mistaken, Netflix use the same infrastructure. Commented Dec 29, 2016 at 15:56

2 Answers 2

1

Your aim is to create REST API so that your customer could use the API. For this you can use :

  • NodeJS to create all your complete application code and Rest API. There are plenty of
  • Java is good to create Rest API. You can use JEE and server you are comfortable with. For example, GlassFish.

My suggestions : Use Java because your current application is on Java. You could save time because working on same language. You already have skills in Java languages. You can use Spring framework ( Spring MVC, Spring Security and Spring Boot). Theses frameworks offer some great features and are simple to learn.

Sign up to request clarification or add additional context in comments.

1 Comment

I've recently looked into Spring Boot as per your suggestion, and I'm amazed at the speedy deployment and documentation available for it. Thanks!
1

Since your current application is already in Java, based on Servlets, the easiest way to create a REST API is just to use the JAX-RS API in your current application. You can start with this JAX-RS tutorial. You would probably also want to use JSON-P for converting between Java objects and JSON. GlassFish, Payara, or any other application server should already provide both the API out of the box.

If you want to use plain servlet container, such as Tomcat, you can add Jersey library to our application, which provides a servlet to support the JAX-RS API in the same way. Or you can alternatively use Spring REST to build the REST API.

I don't recommend to use Node.js just for the REST API - it would introduce a new language for a thing, which can just as easily be done with Java, which is already used by your application. In the end, you would still need to connect the additional Node.js application with the current Java app, which is cumbersome. You would probably end up creating a REST interface between the Node.js app and the Java app, making the Node.js app redundant.

1 Comment

Thanks for the suggestion, I'll definitely stick to one language now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.