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
| 22001 views |
  • submit to reddit

Resources

You can find all examples as Eclipse projects here. All my code stands under public domain if not otherwise stated. So you can do what you want with the examples.

Try the following procedure to get it working:

  • Install gnuplot and adjust the command line in de.wg.core.GnuplotHelper e.g. for windows it should be something like C:\GPpath\gnuplot.exe (I used linux).
  • Then you will need a webserver (I used tomcat) and adjust the location of your webapps folder in all the build.xml files.
  • Build the WebGnuplot project to create the jar in the dist folder (run the build task of build.xml) and change the location of this project in all examples (ant/build.xml).
  • Build all the examples: just run all the ‘build’ ant tasks.

I splitted the examples into several eclipse projects to avoid conflicts (e.g. more than one project uses beanshell) and to compile them independently.

You will have to set up the user libraries for Eclipse to make auto-completion possible. You should put the project specific JAR-files into a subdirectory ‘lib’ of every project.

Define the following user libraries:

  • WebGnuplot: WebGnuplot.jar
  • Servlet API: servlet-api.jar e.g. from tomcat’s common/lib folder.
  • Click: 1 file, 1.8 MB, version: 1.4
  • Echo: 3 files, 0.457 MB, version: 2
  • GWT: 3 files, 11.8 MB, version: linux-1.4.61
  • Thinwire: 2 files, 0.481 MB, version: 1.2 RC2


  • Wicket: 23 files, 8.2 MB, version: 1.3.2

  • WingS: 5 files, 2.3 MB, version: 3.2

  • ZK Framework: 31 files, 19.9 MB, 3.0.3

Maybe you have some usage from the following list, which is based on information from ohloh:

  • Click with 1-3 developer
  • Wicket with at least 4 developer
  • GWT with at least 4 developer
  • Thinwire with 1 developer
  • Echo with 1 developer
  • WingS at least 2 developer
  • ZK Framework at least 5 developer

Please correct my assumptions if I they are wrong!

You can find the original post on my blog Java and more ...

Conclusion

And the winner is …. my brain, hehe.

But which project is the best one? It depends! Do you need commercial support? Do want to integrate it into an existing project e.g. with a pure Servlet solution? Do you want to integrate the UI tests in your regular tests? And so on.

Try the examples or look into the source to get a feeling of ‘how to work’ with a specific framework.

I hope you will have fun!

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.