Simple Java web framework [closed]

If you want a strict Java framework Spark might be an alternative:

import static spark.Spark.*;

public class HelloWorld {
   public static void main(String[] args) {
      get("/hello", (req, res) -> "Hello World");
   }
}

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


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.


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