Is there any simple java web framework like sinatra (for ruby) or web.py (for python)?
I think the simplest thing to do to generate web content via Java is to write a Servlet. Just like web.py allows you to define a GET
method, you can implement a Servlet's doGet()
method and write data directly back to the client.
Here is a link to the Servlets tutorial. You will also need to know how to package and deploy a web application; for that I usually point people to the Tomcat manual (see the section titled "First Web Application").
Writing and deploying a Java web application is not going to be as fast as in Ruby or Python, but Java isn't particularly known for its succinctness.
If you don't strictly require Java, check out Grails. It's a web application framework built on Groovy, which is a dynamic language similar to Python and Ruby that compiles to the JVM.
If you don't require Java, and if you have a small application that does not require an ORM persistence layer, then you might try Groovlets
A Groovlet is a Groovy wrapper over a Servlet. This highly mitigates the verbosity issue of Java servlets. However, note that one will still need to understand servlet basics.
If you are only looking for a presentation framework in pure Java then, for me, Stripes1 is the closest of the Java MVC frameworks to the RoR philosophy: simple, elegant, and requiring minimal configuration.
1 Stripes pioneered the Convention over Configuration approach for Java web development. And while some other frameworks have adopted some of its principles (like Spring MVC or Struts2 with plugins), I still prefer Stripes because it does one thing, and does it well.
The smallest "usable" web server for Java that support Servlets that I can find is Miniature JWS. And honestly there is no reason to run a Java web server that doesn't support Servlets. If you want to do REST, Restlet has a built in HTTP daemon that means you can run it as a stand alone web server.
Play. Haven't tried it myself but heard only good things about it and seems to be quite beginner-friendly.
Java EE 6 Servers like GlassFish bundles it by default.
If you use Tomcat, you can use Jersey, Apache CXF, or Restlet implementations.
Using JAX-RS annotations the web development feels like Sinatra or Merb. BTW you don't have to use Java as the language, you can use Scala, Groovy, JRuby...
HybridJava framework is really simple. Of course, it builds like an API above Servlet API, but deals with page and component instead of request and response. In other words it is truly MVC.
[[JRapid]] is a platform for rapid development of Java web applications. You can define your application using DDD and it generates all the code, including POJOs, Hibernate files, a REST controller and a powerful UI.