views:

1513

answers:

12

Is there any simple java web framework like sinatra (for ruby) or web.py (for python)?

+7  A: 

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.

danben
+ 1 for Grails. I would recommend check out Roo project too
Perpetualcoder
J2EE is dead. Long live Java EE. Here's the right link to the Servlets tutorial: http://java.sun.com/javaee/5/docs/tutorial/doc/bnafd.html
BalusC
@BalusC: Thanks, updated.
danben
Tomcat is no where near a simple as web.py
fuzzy lollipop
A: 

Step is a framework for Scala inspired by Sinatra.

Ken Liu
But Scala is not Java.
jpartogi
That is a true statement.
Ken Liu
Why would you want to write java code if there are better languages for the JVM. I like Step.
Luke
step has been renamed to scalatra http://www.scalatra.org/
tommy chheng
A: 

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.

Michael Easter
+2  A: 

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.

Pascal Thivent
Have you used it professional? Does it fit well with ajax and javascript?
darko petreski
@darko Yes, and it has been a pleasure to work with. Regarding AJAX and JavaScript, have a look at the [AJAX](http://www.stripesframework.org/display/stripes/AJAX) section and the various [User Addition](http://www.stripesframework.org/display/stripes/User+Additions) on the official website, or the [The Stripes Book Blog](http://www.stripesbook.com/blog/) for more examples.
Pascal Thivent
A: 

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.

fuzzy lollipop
A: 

I can recommend Struts2 to you, because i like the plugin architecture and with the convention plugin it is simple and fast to develop.

jogep
+3  A: 

Play. Haven't tried it myself but heard only good things about it and seems to be quite beginner-friendly.

Helper Method
play is pretty cool. I was quite impressed by the tutorial.
Andreas_D
Oh, a (nearly) direct neighbor from Trier ^^. I'm from Saarbrücken.
Helper Method
A friend of mine played with it for a while. He seemed to be satisfied with it.
Thomas Owens
Play is fantastic - I've used in on several projects. Important advantages / simplifications that Play offers:1. Self-contained web server. No need to deploy as a WAR to a separate web container (like Tomcat)2. MVC without servlets3. Change source code, save, refresh browser - no need to deploy a new war. = very fast development.4. Just very simple and easy to learn5. Uses ORM (Hibernate by default) for simplifying database interaction
Mark S
+3  A: 

JAX-RS.

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...

Hendy Irawan
A: 

It is possible to use sinatra as is with jruby

Yuval Rimar
A: 

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.

Alex
A: 

[[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.

Juan
A: 

Check serfj serfj.sourceforge.net.

Yossarian