Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'm currently developing a application that will respond to HTTP requests and spout out raw JSON to the client, but I'm not sure what to use.

I was thinking of using a Java HTTP Server class and handle the requests myself, query my database, construct my JSON, and send it out to the server. The pros would probably be that it would be a single-file application listening on specified port without any external applications.

There is also the Play! Framework which, to me, seems to simplify all this for me, but -- correct me if I'm wrong -- is compiled to a WAR and deployed to something like Tomcat?

share|improve this question
Use the framework: don't reinvent the wheel. – acdcjunior May 29 at 22:29
Nothing is ever compiled to a WAR (or JAR or any other xAR). The compiler output is byte code in the form of .class files that are packaged in an archive like a JAR. And a WAR can contain JAR files. And regarding Play; it has it's own bootstrap mechanism and is not deployed to an application server like Tomcat (that could be done in Play 1.x version but not in the 2.x versions). – maba May 29 at 22:30

closed as not constructive by BalusC, Ɓukasz Lech, Andrew, freejosh, Mario May 30 at 20:39

As it currently stands, this question is not a good fit for our Q&A; format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

3 Answers

I don't know anything about the Play! framework, but, unless you have a burning desire to write your own HTTP server, I would definitely go for a framework of some description.

If you were to split the work in to two chunks, the work required to write and test the HTTP server, and the work to implement the business logic, I'd guess that the work involved in writing your own server would outweigh the work required to develop the software that actually does the work your application relies upon.

share|improve this answer

Play provides a bunch of goodies out of the box, and the development environment is pretty sweet too. To test your changes, you simply refresh your browser, that's it.

The only exception is that when you change your configuration, such as Build.scala, you probably want to do a clean, sometimes you need to reload your eclipse project by running eclipse with-source=true.

There are at least two ways to deploy your job in production:

  1. Use the Play start script

    When you run it in development environment, you use run

    When you run it in production environment, you use start

  2. Create a war, and deploy it through Tomcat In Build.scala, you can have something like:

    val main = play.Project(projectName, projectVersion, appDependencies).settings(Play2WarPlugin.play2WarSettings: _*)
    
share|improve this answer

Your question is very general, so answers will be general too.

Play (in this post I will refer to version 2+) has many features built-in like router, sessions, memory-cache, DB support, job scheduler (Akka), MVC, etc, etc. I like to use Play to built public APIs, however in most of my cases these APIs are just an addition to some web-app.

If you plan a large traffic on this API (from many clients, with many calls per second) that would be good choice, as you can make good usage of the described elements (cache would be most interesting feature in this case).

On the other hand, Play's small app with all basic libs weights ~50mb, so if you plan to publish really simple API which will render single data set and it need to serve only few request a day, maybe simple construction will be just easier and lighter solution?

Finally: Play works on it's own server and it's best option, it's fast, built-in, doesn't require any additional config, just dist your new app and run it on some port. If you definitely want/need to deploy your application as a WAR you can do it. Although Play 2.x has NOT built-in WAR support, you can use a plugin dedicated to this : https://github.com/dlecan/play2-war-plugin/

share|improve this answer
Thank you! This was very helpful, i've started using play now and i like it a lot so far! – Oscar Linde May 30 at 18:35

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