Can Anyone Recommend a Simple Java Web-App Framework

Can anyone recommend a simple Java web-app framework?

Haven't tried it myself, but I think

http://www.playframework.org/

has a lot of potential...

coming from php and classic asp, it's the first java web framework that sounds promising to me....

Edit by original question asker - 2011-06-09

Just wanted to provide an update.

I went with Play and it was exactly what I asked for. It requires very little configuration, and just works out of the box. It is unusual in that it eschews some common Java best-practices in favor of keeping things as simple as possible.

In particular, it makes heavy use of static methods, and even does some introspection on the names of variables passed to methods, something not supported by the Java reflection API.

Play's attitude is that its first goal is being a useful web framework, and sticking to common Java best-practices and idioms is secondary to that. This approach makes sense to me, but Java purists may not like it, and would be better-off with Apache Wicket.

In summary, if you want to build a web-app with convenience and simplicity comparable to a framework like Ruby on Rails, but in Java and with the benefit of Java's tooling (eg. Eclipse), then Play Framework is a great choice.

Does it make sense to use a framework for a simple java web app?

It makes a lot of sense. My team has spent the better part of five years with our open source stack and no matter and we have a "seed" project (works like appfuse) that we use to create all new web apps. Even the simple two pagers from the pov of maintaining the app, it looks like every other app, just smaller.

The short is you won't get any return on the investment right now, but you will as the project evolves and you maintain it.

Can anyone recommend a java web-framework for large application?

Personally, I don't like super-frameworks - they tend to be overly complicated, under featured, and nearly impossible to change. They also have a problem with experienced developer community, and are at risk of major obsolencse. Better off starting from a good base, with LOTS of developer expertise, like Spring, Struts, Seam or Tapestry.

Don't overcomplicate things.

Lightweight Java web framework - specific requirements

How about Play Framework?

Convention over Configuration

Play only has few configuration files. Most of its structure is by convention.
For example the basic structure goes like this:

|
+---/app - All executable artifacts go here (java files, conf files and view templates).
| |
| +---/model - Your model Java classes.
| |
| +---/view - Your view templates.
| |
| +---/controller - Your controller classes
|
|---/conf - Contains all configuration files for the application. Initially contains application configuration and routing table.
|
|---/lib - Libraries your appliaction needs. Added automatically to classpath.
|
|---/log
|
|---/public - Public stuff are your static assets that your server gives directly
|
|---/test
|
|---/tmp - All your temporarily compiled .class files are here

No XML configuration except for web.xml

Play has no XML configuration, including no web.xml. It has a Routing file instead. See the example below what it uses for routing.

Pure Java (no Scala, no Groovy, ...)

It's pure Java, but you can use Scala or Groovy through a plugin.

  • natural REST-style URLs such as /news/2011/july (no .do, no .jsp, ...)
  • REST-aware

From the site:

Play is a real "Share nothing" system. Ready for REST, it is easily scaled by running multiple instances of the same application on several servers.

In fact routing in a Rest like manner is quite easy:

 # Play 'routes' configuration file…

# Method URL path Controller

GET / Application.index
GET /about Application.about
POST /item Item.addItem
GET /item/{id} Item.getItem
GET /item/{id}.pdf Item.getItemPdf

It's not hard to guess which goes where once you get used to Play a bit.

  • it shouldn't force me to deploy on an application server (e.g. EJB should be optional)

It doesn't. In fact you deploy by saving your files. EJB are completely optional and so are .war, .ear and other forms of deployment.

code generation as in Rails would be awesome but not mandatory

I don't think it does much code generation but I'm not 100% on that. It does automatically create all required folders and instantiate a basic example page. I don't know if Rails generates anything else...

MVC would be nice, but

- I'd like to be able to choose the M part, choose the persistence libraries on my own (no bundling).

- No automatically generated code for the view, neither HTML, Javascript, nor CSS

- An integrated template language would be nice, but it should be minimalistic (simple control flow,

See MVC in Play

  • Think this is a minor counter point. Play models must use JPA or extend certain Model class which comes with Play. See Play framework-model for more info.
  • It doesn't generate HTML though you can use your template language inside your .html,.css,.js and other files to create dynamic pages.
  • I has inbuilt template language based on Groovy template language e.g.

    You have ${emails.unread ?: 'no'} ${emails.unread?.pluralize('email')} !

Other pros:

  • It's quite fun to programm in.
  • Did I mention the hotswap that allows you to redeploy your app by saving source files?
  • Great error logs.

Cons:

  • It's 51MB not sure if this qualifies as lightweight :/

Simple Java web framework

You can run Tomcat/Jetty on port 80. Just edit the server.xml (for Tomcat). On Unix/Linux port numbers < 1024 are for privileged users so you would need to run tomcat as root.

Also, running Java web apps is a little bit different than using a LAMP (or a similar) stack. You do still need to understand the concept of a Web/Servlet container

http://en.wikipedia.org/wiki/Servlet_container

Familiarize yourself with the a typical structure for a WAR (Web Archive) file. This is no different than learning about how Apache works and familiarizing oneself with basic Apache configuration with working with a LAMP stack.

This is the bare minimum one should do when venturing into Java Web development.

Take a look at web4j http://www.web4j.com/ I have never used it but it looks simplistic enough for your needs and should get you started

Is it possible to build a Java web application without using a framework?

You can go a very long way with just servlets and JDBC. Consider JSPs using JSTL as an added nicety.

But I'd bet that if your web site consists of more than a page or two delivering database content to the browser, you'll quickly discover why web frameworks are so numerous. Hard-wired page navigation, control logic, blurred layers, etc. will cause headaches as your site grows.

You'll find you have a lot of similar, repetitive, but slightly different code for each bit of new functionality. If you have to maintain a site and keep it going, eventually it's likely that you'll reach the conclusion that there are patterns ripe for capturing. Who knows? Maybe you'll decide as a result of your experience that you want to take a crack at solving the web framework problem, too.

Whatever you do, I think having distinct layers is key. Don't have servlets do all the work - they're for handling HTTP requests. Embed the work in service classes that your servlets can simply call. That way you can reuse that logic. Keep persistence code in its own layer and don't let it leak out into others. You can have reusable components that will survive your first efforts. If you decide to switch to a web framework you'll just snap these layers into place and off you go.

I wrote my first significant web site without any frameworks - just straight servlets, JSPs and JDBC. It gave me a better understanding of what was going on. I think it helps.

can you recommend a workflow library or framework for a Java web app?

Try Activiti. You can define your actual workflow process in either XML or you can use the Eclipse plugin that allows you to model your workflow graphically.



Related Topics



Leave a reply



Submit