Thursday, November 29, 2012

Back to JSP

Alright, so JSP is old and perhaps no longer endorsed by Oracle (there's no section on JSP in the Java EE 6 tutorial).  But it, I find, remains a sane, mature, and better-supported choice of technology for generating web content.  Many other templating engines suffer from lack of support and continued development (due to less usage), crippled integration with other technologies (i.e. frameworks), or unsatisfactory tooling.

Most of the hate-bordering rants on JSP that I see have nothing to do with the JSP technology itself.  The problems they face arise from anti-patterns: spaghetti code, lack of separation of concern, or simply outdated version of JSP spec.

What would be cool for the next JSP spec update is a way to supply partial XML directly from the controller, like that in Lift web framework.  With CDI, yeah.  Something like:

@Produces
@XmlNode
@Named("calendar")
def getCalendar:XmlNode = {
  return 

Calendar

Monday to Sunday
}

Saturday, November 10, 2012

JAX-RS ftw

I never realised this before, partly because the Java EE 6 documentation doesn't make it obvious, but apparently one can use the JAX-RS to create web page controllers.  It seems to be implementation specific, however.  JBoss Resteasy, with Seam Resteasy, has built-in support for freemarker and Velocity templates as well as undocumented for JSP.  Jersey, on the other hand, afaik, only does for JSP.  It's pretty snazzy considering the features JAX-RS has and its deep integration with the Java EE stack--all those REST methods, CDI scopes, streamlined authentication and authorization, etc.
Bottom line, Java EE 6 hasn't abandoned stateless web!  Or something like that.