Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I've been trying to hack up an annotated Spring MVC web app but it's proving pretty hard to call a URL of my web app which fires a request to a remote API (UK Police data) and recieves a reply which I can then return as JSON. I've been trying to use Spring's RestTemplate.

The odd JavaScript example that I've glanced at does seem to be suited to that task a lot better and more simplistic than a full blown servlet. Is that an opinion that you also share and can back up with a good, clear simple example?

JavaScript does seem to provide a good platform for this kind of task

Or, in other words, is it simpler to create a "web-app" with JavaScript that does some REST calls and renders the response than trying to do it with Spring?

share|improve this question
    
Is the question whether you should do the UK Police-rest call from the web browser or from the server (acting as a proxy for the browser), or are you talking about replacing your Java servlet with something like node.js? –  Martin Wickman Mar 12 '13 at 10:11
    
Martin I'm open to an answer focusing on either or both of those questions. I'd like to know opinions about what JavaScript and node can do for me instead of trying to stumble through Spring's RestTemplate. That's why I wondered about the format of the question because it might leave an open question of strength's/weaknesses of JavaScript v Spring –  Crowie Mar 12 '13 at 10:22
1  
Apple or an Orange ? –  NimChimpsky Sep 19 '13 at 13:24
add comment

closed as primarily opinion-based by gnat, MichaelT, Dan Pichelman, thorsten müller, Kilian Foth Sep 23 '13 at 8:53

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise.If this question can be reworded to fit the rules in the help center, please edit the question.

2 Answers

up vote 3 down vote accepted

Javascript and JSON do go hand in hand (JSON == JavaScript Object Notation after all).

You can use Javascript on the server side and it's becoming increasingly popular, (e.g. Frameworks like node.js are being used). However, Javascript has not been a long term proven technology in this space (let the howls of outrage begin), so it's a case of let the buyer beware.

Using Spring MVC, Java, .NET, PHP, Python etc on the server side to process JSON request/response should be fairly easy in 2013 (although sometimes much confusing documentation is lying around as the state of play has changed so much).

I'd post a question on stackoverflow with your specific Spring MVC issue - I suspect you'll get some good answers quickly there. Make sure you specify what type of request (GET/POST etc) and what version Spring MVC you are using.

share|improve this answer
add comment

Simply declaring @Produces("application/json") and installing the appropriate marshaller should take any compatible DTO and produce JSON

as for "proven"/"not proven" this is a puzzling statement. It's a syntax for representing an Object graph. JSON is natural as rain for integrating with a front-end because a Javascript object can simply assign to a webservice call to get at the results.

It's "proven" to represent the same object graph with approximately 50% less data on the wire than xml. You can prove this anecdotally by simply submitting a curl call to any url as '-H "accept: application/json" and then the same call as "-H "accept: application/xml"' and piping those results to "wc -c"

Does it meet your needs? Who knows. Use your best judgement.

I was a big proponent of XML until I actually did some legitimate analysis between JSON/XML. A whole lot less data for no extra work and natively FE compatible. For me, it works.

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.