Defending ugly old JSP.

Russell Beattie complains about the ugliness of JSP, even with the improvements of JSP 2.0. I have to agree. JSP is ugly. JSP also does very poorly in the separate-logic-from-presentation department, scoring an entanglement index of five - and JSTL does not help at all. JSP is butt ugly, but in JSP's defense:

  • It is possible for JSP source code to be valid XHTML. Russell could have done this in his mock-up example by setting a variable and then using the ${var} syntax instead of using "an embedded x:out tag within the href attribute". In theory, by validating your JSP source code as XML and by pre-compiling the JSP at build-time you can weed out a lot of potential errors.

  • Other popular web template languages are just as bad. Velocity, FreeMarker, and Tapestry's template language all have entanglement indexes of five as well.

  • The option of embedding Java code in JSP makes JSP very powerful. Like C++, JSP gives you enough fire-power to blow your entire leg off with one pull of the trigger.

  • Compiling down to Java byte code makes JSP very fast.

  • JSP is an accepted Java standard, it's built-in, it's well understood, and it's easy to find experienced JSP developers.

That last point seems important to me. Perhaps it is not justified and I'm just a Sun lemming, but I'm a little wary of Java web frameworks that attempt to completely side-step JSP.

This just in.

Deadlines still suck - so get the coffee brewing, it's gonna be a late night.

ECMA Standard C# - a clever trap set by Microsoft.

Havic Pennington: Microsoft has set a clever trap by standardizing the core of the CLI and C# language with ECMA, while keeping proprietary the class libraries such as ASP.NET and XAML. There's the appearance of an open managed runtime, but it's an incomplete platform, and no momentum or standards body exists to drive it to completion in an open manner. Many interesting class libraries are clearly encumbered by Microsoft IP and nobody concerned about legal liability will want to ship them. The core may also be encumbered, though that remains uncertain.

Aside from IP issues, Microsoft controls the .NET platform. They will always be ahead, and it will always be tuned for Windows. This is the wrong direction for free software, if we want to win the war, and not only some battles.

That's from an interesting article by Havoc Pennington of the GNOME project, who is currently considering a move from C/C++ to Java or C#. Found via JRoller blogger Emil Eifrem

Why am I doing this Control Flow stuff?

Maybe I should explain why I'm wasting valuable late-night Roller development time with this continuations stuff. I'm experimenting with Control Flow because I'm frustrated with Struts (and other web-MVC frameworks) lack of support for building complex web applications where user-interactions extend over multiple pages. I'm tired of little ad-hoc tricks like session attibute here, request parameter there, breadcrumb stacks, and hidden fields that developers must remember to place on each page. There has got to be a better way and a continuations-based approach seems like it may be that better way. Ken McLeod explains the appeal of a continuations-based approach quite nicely:

Ken MacLeod: Continuation-based web frameworks let you write complex, modeless, interactive web applications in a top-down, linear fashion as simple as writing command-line based applications that prompt for input.

That sounds great, but I don't really want to switch to a new framework to take advantage of a continuations approach. I've got an investment in Struts and JSP and what I would really like to do is to learn from the continuations-based frameworks and, if possible, apply that knowledge to my existing webapps. What I would like to learn is:

  • Should you write entire webapps as "top-down, linear" programs, or should you just use a continuations-based approach for portions of webapps, perhaps only the parts that involve multi-page user-interactions. Charles Miller points out an important reason why you might not want to take the entire-app approach: webapps must be able to provide meaningful and bookmarkable URLs (cool URLs) and some continuations-based frameworks make this difficult.
  • Does it make sense to use Control Flow in the context of a plain-old web-MVC based framework (e.g. Struts, Webwork). How would you do this? Does the Control Flow script kick in before an Action is run, as part of the Front Controller, or after the Action completes?
  • Does it make sense to use Control Flow in the context of a next-generation web-MVC based framework with events and server-side UI components (e.g. JSF, Tapestry)? How would you do this? How should the Control Flow engine fit into the component request/response lifecycle?

There you have it. Please, leave a comment if you have any insight into any of the above questions.

Prevalent Continuations

by Ken MacLeod

Control Flow is free!

After some late night hacking sessions, I've been able to rip Cocoon's Control Flow component free of Cocoon. I removed all dependencies on Cocoon and Avalon and pared my standalone version of Control Flow down to only 14 classes and a couple of JavaScript functions.

Below is the simple JavaScript code that I'm using to test Control Flow. This code will eventually run on the server side and will send a web page to the user when it needs input. The forwardAndWait() method puts the name of the page or Struts forward into a 'tray' object and suspends execution. Eventually, it will suspend execution of the script, call a JSP page or a Struts forward, and wait for the response to go out and the request to come back in.

function test(tray) 
{
   log.info("I called my script!");
   forwardAndWait(tray, "page1.html");
    
   log.info("I'm back in the script");
   forwardAndWait(tray, "page2.html");

   log.info("all done!");
}

Below is the code I'm using to run and test this script. Step #1 sets up the 'tray' that I use to get the forward name and continuation id out of the JavaScript world. I introduced the tray concept, and I don't really like it but I'm not sure how else to get the values I need out of JavaScript. Step #2 and #4 are the interesting bits. Step #2 calls the JavaScript method, which executes and then suspends the script execution inside the 1st JavaScript forwardAndWait() call. Step #4 resumes execution of the script using the continuation id found in the tray.

JavaScriptInterpreter interp = new JavaScriptInterpreter();      
interp.initialize();     
interp.register("C:\\allfiles\\scratch\\StrutsFlow\\src\\flow\\system.js");
interp.register("C:\\allfiles\\scratch\\StrutsFlow\\tests\\flow\\test.js");
      
Scriptable s = interp.enterContext();
      
// 1. setup tray param to hold forward
List params = new LinkedList();
List tray = new LinkedList();
params.add(new Argument("tray", tray));

// 2. call function
interp.callFunction("test", params);
     
// 3. funcion suspended, now tray should contain forward name
assertTrue(((String)tray.get(0)).equals("page1.html"));
// and the continuation id
String kontid = (String)tray.get(1);
      
// 4. resume exection of script using that contination id
interp.handleContinuation(kontid, new LinkedList());
      
// 5. function suspeded again, now tray should contain second forward name
assertTrue(((String)tray.get(0)).equals("page2.html"));
      
// 6. resume function, so it may complete execution
kontid = (String)tray.get(1);
interp.handleContinuation(kontid, new LinkedList());
      
interp.exitContext(s);

And below is the debug output from running the test code above.

JS-INFO: I called my script!
JS-DEBUG: WK: Just Created New Continuation 4d281a763e7c1b3f5a7b4e244b2e224729112160
JS-INFO: I'm back in the script
JS-DEBUG: WK: Just Created New Continuation 877d715e813c5a7c4e7f1a56612826332f528167
JS-INFO: all done!

Next, I'll try to implement the same NumberGuess example from the Control Flow tutorial, but with no Cocoon - only JSP and Servlets.

TriJUG tonight: David Geary talks JSF.

Poised to become the preeminent--not to mention standard--Java Web application framework, JavaServer Faces is the next big thing for server-side Java. Come find out what all the fuss is about in this cutting-edge session given by a member of the JSF Expert Group. Learn what JSF has to offer, how it compares to Struts, and how you can start using it today.
For more info and directions: TriJUG JSF Talk Announcement

Struts Flow

I'm having too much fun hacking apart Cocoon's uber cool Control Flow component to even think about blogging right now. I want to experiment with Control Flow in a simple Struts-based app, but at this point I'm still trying to get my standalone verson of Control Flow working in a simple unit test. If and when I come up for air, I promise a full report.


RSS Quiz


Thou shalt separate business logic from display.

Terence Parr, Enforcing Model-View Separation in Template Engines (PDF): Without exception, programmers espouse separation of logic and display as an ideal principle. In, practice, however, programmers and engine producers are loath to enforce separation, fearing loss of power resulting in a crucial page that they cannot generate while satisfying the principle.
Excellent paper, found via Bill de hOra - a good read for any web developer.

1st Struts-Faces nightly

found via Andrew Kuzmin's weblog

Roller 0.9.8.2 out shortly.

Since the Roller 0.9.8.1 release, I have made a number of fixes in the stable ROLLER_098_BRANCH to support JRoller including: additional database indexes for performance, referential integrity fixes, and RSS encoding fixes. Rick Ross will be happy to hear that, with the latest round of fixes, I have finally killed the dayhits rollover bug. I have deployed Roller 0.9.8.2 to JRoller and if all goes well over the next 24 hours, I'll release it on SourceForge.

In other news: Roller 0.9.9 is progressing nicely and is probably less than a month off. See also: Roller's JIRA roadmap.

Thanks Jaap!

Shortly after I internationalized the Roller JSP pages, Jaap van der Molen sent me a complete Dutch translation and an offer to update it as needed. Thanks Jaap!


Hard to imagine a worse model for UI development than HTTP.

Abstract: Using Smalltalk to Redefine Web Development It would be hard to imagine a worse model for user interface development than HTTP. Would you use a GUI framework where every event from every widget in your application was handed to you at once, periodically, as a large hashtable full of strings? Where every time a single piece of data changed you had to regenerate a textual description of the entire interface? Where the event-based architecture was so strict that you couldn't ever, under any circumstances, open a modal dialog box and wait for it to return an answer?
[...]
For all its limitations, the web is fast becoming the most important deployment platform for many classes of application. The Java, Perl, PHP, and .NET worlds, to name a few, are pursuing it agressively. Many of us are going to have to play their game -- but we don't have to play by their rules.
That's part of the abstract for a talk on Seaside, a Smalltalk and continuation based web application development framework (via James Robertson's blog). Seaside is one of many continuation based frameworks. The more I read about these frameworks the more I become convinced that the holy grail of web development lies in the castle of continuations. I've previously mentioned the two Java entries in the quest for the grail: RIFE and Cocoon ControlFlow. I need to find some time to investigate these frameworks and figure out how they relate, if at all, to JSP and JSF.

Deadlines suck.

That's all.


7% of adults blogging?

Pew Internet Project Report

Another prediction.

I'm going to go out on a limb and make another prediction: Roller 0.9.9 will ship with a kick-ass (forgive me, I'm from North Carolina) Atom implementation that is not named after a washed-up SNL cast-off. Zing!

« Previous page | Main | Next page »