0

I would like to add a Web User Interface for an existing Java project I did time ago. I learned basics of AngularJS on codeschool.com courses and now I know how to send an http or REST request to get data for my web UI. My Java project has a set of methods that elaborate some data from a local database and return integers or integers arrays.

The goal of the interface would be to show a bunch of charts and data directly from that Java project.

What would be the most appropriate way to do this? I heard of implementing REST services on my Java project but it seems overkill for the purpose and i'm totally confused by all the frameworks for this. What would you use?

Thanks everyone for your answers!

1
  • REST is definitely the way to go when the frontend is pure JS. Commented Jul 10, 2014 at 10:25

3 Answers 3

1

I would use SprinvMVC to provide data from server to client side.

Here is my project from which you can start and learn basics : https://github.com/xwid/thaimaster

Basicly you should create spring controllers mapped to urls, by doing it this way, you will be able to retrive server data using angular js.

http://www.javabeat.net/spring-mvc-angularjs-integration/

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

2 Comments

If the OP is not familiar with Spring, this is probably not the best suggestion.
He said he is totally confused by all the frameworks, that's why i provide simple runnable example. I think those fameworks makes things as much simple as possible.
0

If you don't want to use a full REST framework such as Jersey, another possibility would be to use an embeddable HTTP server (there are several) and handle the requests yourself. This would mean that requests to something like /myapp/ would return your AngularJS filled HTML page, and requests to /resources/* would provide with REST functionality.

This would give you a standalone Java program that doesn't need a servlet container, but it would be a somewhat hacky solution. Not production grade, but you'd probably learn something from having to handle the HTTP traffic yourself.

Comments

0

With the Spring Framework's SprigBoot, it's quite easy to implement a REST service and have a runnable java application. You can follow this Building a RESTful Web Service guide from spring.io. They are clear and quickly understandable.

Also if you are not already familiar, through these guides you can have a glimpse of gradle and maven as well.

Comments

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.