I'm currently reading this free book: http://pdf.coreservlets.com/
It is very well written, and explains lots of things I have been in the dark about these past few weeks at WirelessCar.
The first half of the book covers servlets. Servlets generate webpages via Java code. The second half of the book covers JSP (Java Server Pages), which are in essence HTML and / or XML documents with bits of JSP specific stuff in them, the conceptual inverse of servlets (JSPs are actually magically converted into servlets when they are accessed by a client). So JSPs use markup to generate code that generates markup.... erhm...
I doubt that anyone will be surprised to hear that my gut feeling is that I wouldn't mind writing servlets, but I would hate messing around with JSP.
First of all, Casey at Molly Rocket made a really good point in that code is more powerful than data. Servlet code, being Java code, being compilable, will not make you want to gouge out your eyes due to a typo you can't find.
JSP is data that wants to be code (with 4 different ways of embedding dynamic stuff inside of HTML, each with its own scary ass syntax). Well, maybe the capability of embedding straight Java is kind of ok. In any case, for this crap to be compiled into a servlet, you need to actually access the page, and of course maybe you made a typo and it won't even compile. Talk about jumping through hoops.
Sure, I can accept that when you have lots of static content on your page and just need a little bit of dynamic stuff, inlining some java statements in basically pure HTML wouldn't be all bad. But put a fucking cutoff on that shit somewhere! For every new technique of adding dynamic content to JSPs that is presented in the book, it just feels more and more like they wanted it to be a real programming language. It's not. It's a fucked up macro-shit-mess.
I remember the kind of pain and suffering we caused for ourselves at Massive with our various scripting languages, not really wanting to code stuff but also not really wanting to just have it be a definition language. Argh!
The book also explains what it calls a MVC approach to webapp development, with servlets handling the logic and JSPs handling the presentation. Sure it's better, but it stinks RM to high heaven. Lots of intermediate caching of stuff in so called JavaBeans (that spec is a joke), and a heavy dose of C-style procedural programming.
However, I have a gut feeling that it would be possible to use an IMGUI style approach to all of this. I'm still formulating the idea right now, but it would involve using a servlet to control how the user interface (the resulting HTML pages) got generated, most likely using a powerful HTML generator that looks like our IMGUI contexts (DoButton(), DoLabel() etc).
The goal is to allow the View servlet to generate a dynamic page based on traversing session data (internal view details) as well as Model data (the enterprise backend) on the fly for each request. This would limit the amount of stupid-ass JavaBeans flying around (evil caches), and probably limit or remove the need for any JSP.
As the new spec of Enterprise Java Beans (EJB 3.0) does a good job with persistence (using the Java Persistence API) I am not worried about the Model side of things, and I think it will be possible to emulate the IEventTarget pattern as well.
Submitted by johno
Thu, 09/27/2007 - 15:53