Hacking on GraphHopper - a Java road routing engine. Peter has posted 62 posts at DZone. You can read more from them at their website. View Full User Profile

Java Web Frameworks Survey

04.13.2008
| 22266 views |
  • submit to reddit

Results

Swing

As the first step I created a Swing UI within 3 minutes - I will compare this later with the web frameworks.

On the right side you see a screenshot of the result. (It is not nice, but it was fast … and well, late)

 

Additional Information:

  • User Libraries: ‘WebGnuplot’ (See the resources section)

Click Framework

Click is comparable to Wicket, but I think it is slightly easier. It is a lot easier than JSP, because you don’t need getters and setters (i.e. an extra bean) - just the variable (e.g. form) which will be mapped to the HTML correspondent ($form), which is an identifier of the used scripting language (velocity). This means you haven’t to know the HTML specific components like in wicket, although it is a plus if you know them. It took me about one hour to get it running. I didn’t try the adapted Eclipse (clickIDE), but with this IDE you should easily edit the HTML file’s e.g. velocity support for the editor.

 

Additional Information:

  • It seems to me that click integrates very good with Cayenne. Cayenne is an object relational mapper (ORM) and a nice (easy!) alternative to e.g. Hibernate.
  • I needed an extra servlet, which returns the image as an OutputStream.
  • A nice page returns if an error occurs with a lot of details and the full stack trace.
  • User Libraries: ‘Click’, ‘WebGnuplot’ and ‘Servlet API’ (See the resources section)
  • License: APL 2.0

Echo

Echo2 ResultsEcho was the first web framework I tried. It was very easy and fast to get it working (less than 30 minutes). The only big difference to Swing was the AwtImageReference class, which I had to use for displaying in the label. It is nice that a message window pops up (’Please Wait…’), if the response of the server takes too long.

Additional Information:

  • User Libraries: ‘Echo’ and ‘WebGnuplot’ (See the resources section)
  • License: MPL


Google Web Toolkit

The Google Web Toolkit works different compared to all other frameworks. So it took me a lot of time (over five hours) to get it working and understand what to do. I will explain the procedure now.

  • You will have to compile the Java sources. Put the server side source into a sub-directory ’server’ and the client side sources into ‘client’. To compile the source you have to call ‘GWT-application-compile’ for this example. For the client side the compilation step generates Javascript sources from Java - to be executed on the clients webbrowser. And for the server side the Java code will be compiled and GWT generates e.g. the web.xml and some more files.
  • Then you can run your application in a standard browser, if you deploy the application to the server. But there is another mode, they called it ‘host mode’, where client AND server code run on the virtual machine (jvm). Then you can test your application directly within Java, which I found to be very useful for debugging.
  • For the interaction between client and server the GWT uses Java’s remote procedure calls (RPC). I will use it in the example, because the Image class does not support bytes or BufferedImage as input. So I send the gnuplot statements to the server (via RPC) and then the client reads the image from a separate ImageServlet (which knows the statements). This routine is a little bit complicated, but otherwise I wouldn’t use RPC and cannot show you how it works ;-)

Another concept of GWT is that you have to define ’slots’ within the HTML files. From Java code you can access those slots via:

VerticalPanel vp = new VerticalPanel(); 
vp.add(button);
RootPanel rp = RootPanel.get("appSlot");
if(rp != null)
{
rp.add(vp);
}

This makes it easy to integrate GWT in your current development. E.g. to enhance static content with some AJAX.

Additional Information:

  • User Libraries: ‘GWT’ and ‘WebGnuplot’ (See the resources section)
  • GWT is a client centric framework
  • It is possible to let GWT create an Eclipse project for you if you want easy access to compilation but I didn’t try this.
  • There is a NetBeans plugin, which makes development very easy (without that I wouldn’t have figured out where my configuration mistake was…).
  • You will have to replace the linux specific jar with the jar of your own operating system. But I don’t know how to generate a compile and a shell script for this specific project. Normally you would run the ‘applicationCreator’.
  • I needed an extra servlet, which returns the image as OutputStream
  • License: APL 2.0

JSP

JSP was, and still seems to be, the standard technology for a lot of companies to create web projects. It works similar to ASP.

It only took me about an hour to get started.

 

 

Additional Information:

  • User Libraries: ‘WebGnuplot’ and ‘Servlet API’ (See the resources section)
  • I needed an extra servlet, which returns the image as an OutputStream
  • License: APL 1.1

Thinwire

Thinwire’s last published version is relatively old - maybe the authors skipped the development.

Update: This is not true. Look here and here.

I think it is easy to get started (approx. 50 minutes). Although I had some problems:

  • You will have to set the bounds of every component explicitly - this makes it really ugly if it comes to computer generated interface (e.g. Strings withing Labels).
  • It is not easy to display dynamically generated images to the client. Unlike echo and wings, we need here an ImageServlet for this work like e.g. in JSP and GWT.
  • And I had to use the Button class to display an image, because the Image class does not work. This was the reason that it took relatively long to get it working.

Additional Information:

  • If an exception raises you will get a window with the message and a full stack trace!
  • User Libraries: ‘Thinwire’, ‘WebGnuplot’ and ‘Servlet API’ (See the resources section)
  • I needed an extra servlet, which returns the image as an OutputStream
  • License: LGPL

Wicket

In Wicket you will only be successful, if you know some basics in HTML. You will embed the components via HTML tags and access them from Java via id’s. Although it seems to be complicated I got it working within an hour. Maybe that was because of the provided example from the JFreeChart forum. I think Wicket will integrate well in existing environment based upon pure Servlets or JSP.

Additional Information:

  • User Libraries: ‘Wicket’ and ‘WebGnuplot’ (See the resources section)
  • License: APL 2.0

WingS

WingS ResultIt was even a little bit easier than Echo to get started (less than 20 minutes), because there is a class SImageIcon which takes a BufferedImage as a constructor parameter in. So I didn't need to use the documentation - I just used auto-completion of the IDE.

You will typically get a ‘waiting cursor’, if the response of the server takes too long. My feeling was that WingS was a little bit slower than Echo with the task of displaying the image after I pressed the button.

Additional Information:

  • User Libraries: ‘WingS’ and ‘WebGnuplot’ (See the resources section)
  • License: LGPL

ZK Framework

It took relatively long to get started - about 3 or 4 hours. The following are the steps that need to be completed.

  1. You will have to understand how to create a zul file for your UI. But there is a demo application on the web site, where you can find a common usage of every component.
  2. You will have to understand how to get information from the client via Path.getComponent(”/zkWindow/error”); and
  3. how to push the results to the client via:
    AImage image = new AImage(”Image”, bytes);
    myimage.setContent(image);

But after understanding how zk works, it was easy for me to create the necessary classes and zul files. The default layout is very nice as you can see in the screenshot.

Additional Information:

  • User Libraries: ‘ZK Framework’ and ‘WebGnuplot’ (See the resources section)
  • License: GPL or Commercial

4
Your rating: None Average: 4 (3 votes)
Published at DZone with permission of its author, Peter Karussell.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Comments

Bob Schellink replied on Sun, 2008/04/13 - 6:35am

Hi Peter,

Nice work comparing all the different frameworks. I always thought it would be too much work to compare them but you obviously proved me wrong there ;-)

If you have time it would be great to see a follow up post comparing the other frameworks you mentioned: struts, stripes, jsf and jzeno.

I notice for Click you used a seperate servlet to stream the image. It is actually possible to write to the HttpServletResponse directly from your Page, in this case ClickApplication. If the method Page#getPath returns null, Click won't render the page template.

So by adding the method ClickApplication#getPath to return null one can change the ClickApplication#onClicked method to stream the image directly to the HttpServletResponse#outputStream.

One last comment about your click.xml file. You don't need to explicitly map the template to the java class, Click will map them automatically.

Again great work on this.

kind regards

bob

Peter Karussell replied on Sun, 2008/04/13 - 7:47am

Hi Bob!

[quote]I always thought it would be too much work to compare them but you obviously proved me wrong there ;-)[/quote]

Hmmh, but maybe I proved that it was too much work (for a newbie) as it should be ;-)

Hopefully I will have some time to include the other frameworks.

[quote]I notice for Click you used a seperate servlet to stream the image. It is actually possible to write to the HttpServletResponse directly from your Page, in this case ClickApplication. If the method Page#getPath returns null, Click won't render the page template.

So by adding the method ClickApplication#getPath to return null one can change the ClickApplication#onClicked method to stream the image directly to the HttpServletResponse#outputStream.[/quote]

Yes I used a separate servlet and it would be better if i can avoid this. But actually I don't understand how? You mean that ClickApplication.getPath should return null if the page requests the image? Please, could you provide an example for this? Especially for the file ClickApplication.htm.

[quote]One last comment about your click.xml file. You don't need to explicitly map the template to the java class, Click will map them automatically.[/quote]

You mean I could remove the file?

Thanks for your input Bob!

Peter.

Pether Sorling replied on Sun, 2008/04/13 - 9:18am

Nice too see somebody make an effort to try out different frameworks..

Thinwire development team is pretty active they just haven't made any release for a while.

Subversion stats : http://sourceforge.net/project/stats/detail.php?group_id=170706&ugn=thinwire&type=svn&mode=12months

 

More info about the current state of thinwire. 

http://truecode.blogspot.com/2008/04/state-of-thinwire-framework-2008.html

Pether

Bob Schellink replied on Sun, 2008/04/13 - 10:39am in response to: Peter Karussell

[quote=peathal]

Yes I used a separate servlet and it would be better if i can avoid this. But actually I don't understand how? You mean that ClickApplication.getPath should return null if the page requests the image? Please, could you provide an example for this? Especially for the file ClickApplication.htm.[/quote]

Here is an example of how to stream directly: http://www.avoka.com/click-examples/direct-page.htm

However having a closer look at your example you actually want to render a html image tag. I will email you an example of this since it is probably impolike of me to flood the comments with Click code ;-)

[quote]You mean I could remove the file?[/quote]

No the file is still needed, but only the package has to be specified. From that Click will be able to map templates to classes. So you only need:

<click-app>
<pages package="de.wg.web.click"></pages>
</click-app>

kind regards

bob

Daniel Ray replied on Sun, 2008/04/13 - 12:10pm

Wow. What about JSF using MyFaces, RichFaces, IceFaces, or Facelets? Struts? Spring UI? To each his own I suppose.

Peter Karussell replied on Sun, 2008/04/13 - 3:09pm in response to: Pether Sorling

Ups, sorry for this. I will remove the comment in the article now. I thought I looked on the code stats, but really: thinwire is active!

 

Peter.

Peter Karussell replied on Sun, 2008/04/13 - 3:44pm in response to: Daniel Ray

In my planned continuation of this survey I will only cover the usage of MyFaces and Struts, because of my limited time.

Maybe you can do the necessary implementation of the others? :-)

[quote] To each his own I suppose. [/quote]

What do you mean with 'own'? Own implementation? 

Peter.

Bruno Vernay replied on Mon, 2008/04/14 - 3:28am

Interesting, I did my own little research exercise on the subject, it is a never ending work :

http://docs.google.com/Doc?id=ajgdx7ccvkxg_50ccp25f

There should really be a wiki somewhere or some kind of taxonomy to help categorizing / choosing them.

Hope it helps

Jose Maria Arranz replied on Mon, 2008/04/14 - 7:13am

My contribution: Gnuplot Web based on ItsNat

ItsNat is a new Java web application framework strongly focused on AJAX from scratch. Basically the server keeps a W3C DOM tree of the page, the client is updated automatically when the server DOM tree is changed using W3C DOM APIs, in summary: DHTML on the server. Templates are pure HTML files with no logic. ItsNat provides optional components reusing data y selection models from Swing.

This Gnuplot web version is an AJAX application.

I've spent 2 hours and 15 minutes, 50 minutes spent building the application. The remaining time was spent trying to figure how to run Gnuplot: trying to execute the pure windows version of gnuplot (failed, is a GUI), then trying the cygwin version (missing DLL cyggd-2.dll), investigating what cygwin package installs cyggd-2.dll, then installing libgd2 in my cygwin instalation and copying required dlls to setup an standalone version of Gnuplot...

This application runs on:

Desktop browsers: FireFox 1.x, MSIE 6+, Safari 3+, Opera 9+

Mobile browsers (yes including AJAX): Opera Mini 4, Opera Mobile 8.6, Minimo 0.2, NetFront 3.5 and ... IE Mobile 6 (WM6) !!

Notes: ItsNat distribution included is a prerelease of the upcoming v0.3 (current public version is 0.2)

GnuplotHelper class is slightly modified.

Source code summary:

Template:

<!-- <?xml version="1.0" encoding="UTF-8"?> -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>WebGnuplot</title>
</head>
<body>
<h2>WebGnuplot</h2>

<textarea cols="25" rows="10" id="commandsId">
</textarea>
<br />
<input id="plotId" type="button" value="Click me, to run the statements above" />
<br /><br />
<img src="" id="plotImageId" />
</body>
</html>

Template processor:

package webgnuplot;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import javax.swing.text.BadLocationException;
import org.itsnat.comp.ItsNatComponentManager;
import org.itsnat.comp.html.ItsNatHTMLInputButtonNormal;
import org.itsnat.comp.html.ItsNatHTMLTextArea;
import org.itsnat.core.html.ItsNatHTMLDocument;
import org.w3c.dom.Element;
import org.w3c.dom.html.HTMLDocument;
import org.w3c.dom.html.HTMLImageElement;


public class GnuPlotListener implements ActionListener
{
protected ItsNatHTMLDocument itsNatDoc;
protected ItsNatHTMLTextArea textArea;
protected ItsNatHTMLInputButtonNormal button;

/** Creates a new instance of GnuPlotListener */
public GnuPlotListener(ItsNatHTMLDocument itsNatDoc)
{
this.itsNatDoc = itsNatDoc;
ItsNatComponentManager compMgr = itsNatDoc.getItsNatComponentManager();

HTMLDocument doc = itsNatDoc.getHTMLDocument();

Element commandsElem = doc.getElementById("commandsId");
this.textArea = (ItsNatHTMLTextArea)compMgr.createItsNatComponent(commandsElem);

javax.swing.text.Document swingDoc = textArea.getDocument();
String commands = "";
commands += "set xrange[-3:7] \n";
commands += "set yrange[1:5] \n";
commands += "set isosamples 50 \n";
commands += "set hidden3d \n";
commands += "splot exp(-0.2*x)*cos(x*y)*sin(y) \n";
try { swingDoc.insertString(0,commands,null); } catch(BadLocationException ex){ }
// Alternative: textArea.setText(commands);

Element plotElem = doc.getElementById("plotId");
this.button = (ItsNatHTMLInputButtonNormal)compMgr.createItsNatComponent(plotElem);
button.getButtonModel().addActionListener(this);

setImage(commands);
}

public void actionPerformed(ActionEvent e)
{
javax.swing.text.Document swingDoc = textArea.getDocument();
String commands = "";
try { commands = swingDoc.getText(0,swingDoc.getLength()); } catch(BadLocationException ex){ }
// Alternative: String commands = textArea.getText();
setImage(commands);
}

public void setImage(String commands)
{
HTMLImageElement img = (HTMLImageElement)itsNatDoc.getDocument().getElementById("plotImageId");
try{ commands = URLEncoder.encode(commands,"UTF-8"); } catch(UnsupportedEncodingException ex) {}
img.setSrc("imgservlet?commands=" + commands);
}
}

 

imgservlet servlet basically calls GnuplotHelper.getImageBytes(String) and outputs the image to the OutputStream of the request.

Enjoy

 

Jose Maria Arranz replied on Mon, 2008/04/14 - 8:23am in response to: Bruno Vernay

Bruno: There should really be a wiki somewhere or some kind of taxonomy to help categorizing / choosing them.

Some time ago I made a brief categorization of Java web frameworks, it may be useful to you:

Here and here

Regards

 

i honsali replied on Mon, 2008/04/14 - 10:19am

I think that the web framework should also be categorized by development context,
newbies/expert
small/large team
small/complex project
using or not graphic IDE with D&D component.....

personally I think that the best framework is the one you create yourself,

after using 2 or 3 different kind of web framework and once you get the big ideas behind it
it is easy to make one yourself based on velocityView for example

Peter Karussell replied on Tue, 2008/04/15 - 8:23am in response to: Jose Maria Arranz

Hi Jose,

thanks a lot for the example - it works ;-) Can I add this to the 2. part of my survey (under public domain with you as the author)?

Peter.

Jose Maria Arranz replied on Tue, 2008/04/15 - 9:14am in response to: Peter Karussell

Yes of course.

GnuPlot Web's source code is covered with the license WYWTDWT (=What You Want To Do With This)

Igor Vaynberg replied on Tue, 2008/04/15 - 2:35pm

A few corrections about Wicket

1) Comparing Wicket to Click is like comparing apples to oranges. While there are some minor similarities upon first glance, Wicket and Click have completely different focuses. Wicket focuses on stateful components, while Click focuses on stateless ones. In Click you can only have one stateful page instance per its class, in Wicket you can have multiple instances and multiple versions per instance to make the back button work properly. (This is what Click did last time I looked at it, it may have since changed). Advantages of stateful components is that they scale much better in complex UIs since the developer doesnt have to manage state manually, whether that be in session or urls.

2) The dependencies list for Wicket is completely off. Looks like you listed the kitchen sink there.

~/dev/src/wicket/wicket> mvn dependency:tree

[INFO] [dependency:tree]
[INFO] org.apache.wicket:wicket:jar:1.4-SNAPSHOT
[INFO] +- org.slf4j:slf4j-log4j12:jar:1.4.2:test
[INFO] | \- log4j:log4j:jar:1.2.13:test
[INFO] +- javax.servlet:servlet-api:jar:2.3:provided
[INFO] +- org.slf4j:slf4j-api:jar:1.4.2:compile
[INFO] +- junit:junit:jar:3.8.1:provided
[INFO] +- javax.portlet:portlet-api:jar:1.0:provided
[INFO] \- org.apache.portals.bridges:portals-bridges-common:jar:1.0.3:provided

so really only org.slf4j:slf4j-api:jar:1.4.2:compile is required - that is only one jar.

of course if you runs this on wicket-examples project, which demonstrates integrations with spring/guice and a bunch of other modules, you will end up with the kitchen-sink list of dependencies you have.


Cheers

Igor Vaynberg replied on Tue, 2008/04/15 - 3:33pm

Some comments on the attached sources:

WicketApplication can be replaced with just:
public class WicketApplication extends WebApplication {

public WicketApplication() {
}

public Class getHomePage() {
return HomePage.class;
}

}

HomePage can be rewritten in a much more concise form:

public class HomePage extends WebPage {

private static final long serialVersionUID = 1L;

/** graph expression */
private String expression="plot sin(x)";

/**
* Constructor that is invoked when page is invoked without a session.
*
* @param parameters
* Page parameters
*/
public HomePage(final PageParameters parameters) {
Form form=new Form("messageInputForm");
add(new TextArea("statements", new PropertyModel(this, "expression"));
add(new Label("errorText")); // what is this for?
add(new WGImage("image"));
}

private final class WGImage extends NonCachingImage {

private static final long serialVersionUID = -2972050319844348290L;

public WGImage(String id) {
super(id);
}

@Override
protected Resource getImageResource() {
return new DynamicImageResource() {

private static final long serialVersionUID = -4215541582455792421L;

@Override
protected byte[] getImageData() {

try {
return toImageData(GnuplotHelper.getDefault().getImage(expression));
} catch (IOException e) {
e.printStackTrace();
return null;
}
}


};
}
}
}

 

 

Peter Karussell replied on Tue, 2008/04/15 - 5:58pm in response to: Igor Vaynberg

Hi Igor,

thanks for your input.

I didn't want to compare apple with oranges but click and wicket looks quite close to each other for a newbie (to the web frameworks), sorry for this. So, you think Wicket is 'better'?

You mean that I should use NonCachingImage instead of the setHeaders stuff?

The errorText-label I needed for some debugging while I played with the code.

Peter.

Igor Vaynberg replied on Tue, 2008/04/15 - 5:49pm

Peter,

I didn't want to compare apple with oranges but click and wicket looks quite close for a newbie to the web frameworks, sorry.

Well, thats exactly the problem with these kinds of comparisons, to a newbie they might look the same.

So you think wicket is better?

You are asking a wicket committer if he thinks a framework he sinks a lot of his free time into is better then anything else out there? What do you think the answer is? :)

But, if you ask me to compare wicket to another framework I probably would not be able to come up with anything meaningful either. There are some basic design choices that differentiate all the major frameworks, some of them are: state management, markup handling, pojo model, testability, component hierarchy (static vs dynamic), community, books, etc. You can probably figure these out even if you havent used the framework extensively. Then you figure out which of these choices jive more with what you want in the framework for a particular app - and there is your choice.

Another good thing is to ask the community behind the framework for help. Give them a list of assumptions you have come up with and ask for validation.

You mean that I should use NonCachingImage instead of the setHeaders stuff?

Yep, there is no reason to reinvent the wheel by setting the headers yourself.

 

 

 

 

Marcos de Sousa replied on Wed, 2010/07/14 - 3:50am

I use ZK in production environnement since version 2.0.4. All version 2.x.x, 3.x.x, 5.x.x are less than 2.5 MB.

Where did you get 20 MB?

Peter Karussell replied on Wed, 2010/07/14 - 4:01am in response to: Marcos de Sousa

I am sure that you are right. Although I tried to reach the best for every framework. (the licensing of ZK is now also nice!)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.