How would you build your (Java-based) web applications today?

Posted : May 10, 2004 at 8:04 pm [America/Los_Angeles]

Once you get used to building Java-based web (or any type of) applications a certain way, it takes quite an effort to get over your Pavlovian urges to try something new. So, this morning, I decided to do something about it. The way I see it, every programmer in this space should revisit their “way” of doing things every 6 months and make necessary changes hopefully for the better. This exercise should also involve looking at things like your UI design and navigation techniques, use of HTML/XHTML, CSS/CSS2 and Javascript in your applications.

Anyway, so here are some of the permutations and combinations that I came up with:

1. Pure JSP solution:

JSP 2.x using the new EL stuff and the core and fmt JSTL tags (View Layer) + POJOs (Service Layer) + iBATIS/DBCP or Hibernate/DBCP (Persistence) + MySQL/Oracle (Data Layer)

2. Pull-MVC approach using VelocityTools:

VelocityViewServlet intercepting all *.vm requests (Controller) + Velocity (View Layer) + Velocity Tools which are basically arbitrary Java classes exposing methods to Velocity templates (Service Layer) + iBATIS/DBCP or Hibernate/DBCP (Persistence) + MySQL/Oracle (Data Layer). I like this Pull-MVC approach and would like to use something like this for smaller-sized apps

3. Springing Struts:

Struts 1.1 (MVC Framework) + JSP, JSTL, Struts Tags/EL and Tiles (View Layer) + Spring (Service Layer) + iBATIS/DBCP or Hibernate/DBCP (Persistence) + MySQL/Oracle (Data Layer)

4. A (Web)working solution..;-):

WW2 (MVC Framework) + Velocity and SiteMesh (View Layer) + Spring (Service Layer ?) + iBATIS/DBCP or Hibernate/DBCP (Persistence) + MySQL/Oracle (Data Layer)

5. Its Springtime fellas:

Spring (MVC + Service Layer) + Velocity/SiteMesh or JSP/Tiles (View Layer) + iBATIS/DBCP or Hibernate/DBCP (Persistence) + MySQL/Oracle (Data Layer)

6. Scripty Apps:

Building MVC applications using Groovy and Jython. I must confess that while I am pretty excited about the opportunities in this area, I know far too little at this time to make any significant strides in this department

Ok, I think #2, #3 and #4 sound like something that I would like to dabble with first (pretty much in that order). Create an Appfuse Lite type application in these three categories and see which one gives me the most pleasure.

#5 has to be something that I take a stab at after Matt comes out with his book (Spring Live).

As for #6, the only implementation that I have in this space is Thomas Risberg’s neat little Jython + Spring + Velocity App. I luv it’s simplicity. Way too cool. However, this has to be something that I play with the last. May be by that time, there would be some clarity in the “scripty java apps” space with all the press Groovy and Jython seem to be getting.

#1 was listed here for reasons I can’t seem to come up with this second. Oh well

So, what do you think? Is it even worth going thru this exercise? If so, what would be your choices.

Note:

  1. I don’t know much about Tapestry to include it in my options.
  2. The absence of EJBs in this list is by choice. Frankly, I am either not smart enough to “really” get why people use and continue to talk about EJBs or some folks are too dumb (and yet very savvy in Marketing) to be pushing something as “bulky” as EJB for building web applications. Would EJB as an offering stand a chance if it came from someone like me or you as opposed to “Sun Microsystems Inc.”. Probably not.
  3. I need to get a better handle on XHTML and CSS/CSS2. I am sure a lot has happened since the last time I looked at them seriously.

- Anand

Viewed: 3150 times

21 Comments

I would use:

RIFE (MVC), RIFE (Logic and data flow), RIFE (Service layer), RIFE (View), RIFE (Persistence, db abstraction), RIFE (Language independent Components), RIFE (Continuations), RIFE (Authentication), RIFE (Scheduling), PostgreSQL (Data layer)

Sorry for the repetition ;-)

Posted by: Geert Bevin at May 10, 2004 @ 11:19 pm

Sorry to disappoint you Geert, but I have no clue what RIFE is. But then again, why do I feel that you knew that already..;-)

Will give my “15-min” test to RIFE when I get some time. Thx for the pointer.

Posted by: Anand Sharma at May 11, 2004 @ 12:05 am

Sure, I saw your comment about Tapestry, but why not check it out in the Betterpetshop, using Tapestry, Spring and Hibernate:

https://betterpetshop.dev.java.net/

Posted by: Mats Henricson at May 11, 2004 @ 2:26 am

Anand, it’s not like it’s a new framework, it has appeared many times in blogs, been on the java.net frontpage, in development for over 3 years, … but through the huge amount of technology that’s available nowadays it’s difficult to see anything anymore ;-) To start you best use the examples (https://rife.dev.java.net/servlets/ProjectDocumentList) together with the usersguide (http://rifers.org/docs/usersguide/). After that, the jumpstart is great to get you going with new apps (a bit like appfuse which sets up an application structure for you). More about continuations here (http://www.uwyn.com/blog/archives/000057.html) if you’re interested in that.

Posted by: Geert Bevin at May 11, 2004 @ 3:18 am

You forget using one of the better UI technologies, such as Echo or WebOnSwing, etc. They certainly don’t work out on the “web” as such, but make perfect intranet apps. The kind of functionality they give is AMAZING. See it to believe .. I don’t use them, but they certainly are worth looking at.

Posted by: Ashish Kulkarni at May 11, 2004 @ 3:22 am

http://alexwinston.com/blog/2004/05/04/1083708448000.html is comparable to number six but in my opinion is a bit cleaner.

Posted by: Alex Winston at May 11, 2004 @ 5:03 am

Implementation of #6: JPublish. You can use as little or as much scripting as you want since you can freely switch between actions coded in Java or actions coded in any BSF supported scripting language (of which I am currently using BeanShell).

Posted by: Anthony Eden at May 11, 2004 @ 9:14 am

Mats: I like your enthusiasm about Tapestry. Let’s see how much it rubs off on me and forces me to give it a try. I probably will. Thx for the pointer though..:-)

Posted by: Anand Sharma at May 11, 2004 @ 10:06 am

Geert: Hmm, I must say that I feel a little dumb reading your reply to my post. I am not sure how I missed out on the coverage of RIFE at the sites you mention. Thanks for all the links and pointers.

Posted by: Anand Sharma at May 11, 2004 @ 10:09 am

Ashish: Well, in the Rich Internet Application space, I have little or no experience. The only name that I have heard so far is “Flex” and have paid little attention to it. Thanks for adding a few more to my list. Will certainly try to find some time and check it out.

Must say it sounds interesting.

Posted by: Anand Sharma at May 11, 2004 @ 10:12 am

Alex: Cool. Sounds fun. As I was alluding to in my post, #6 will probably be something that I look at last. But I am glad I have something else to look at besides the Jython, Spring and Velocity implementation. Thx..:-)

Posted by: Anand Sharma at May 11, 2004 @ 10:15 am

Anthony: Actually, I should have mentioned this in my post. I really knew a few things about JPublish, but had never tried it out. btw, sorry for being a bit of a neophyte in this field, but is Groovy or Jython BSF supported scripting language. If yes, cool. If no, do you plan to extend JPublish to support writing actions using these languages. - Thx

p.s. On a side-note, your blog (along with Russell and Erik) was one of the first few blogs that got me “hooked” on to this blogging mania. Thank you for taking the time to write!

Posted by: Anand Sharma at May 11, 2004 @ 10:23 am

Yes, both Jython and Groovy have BSF interfaces. In fact the three scripting languages which are automatically included in the JPublish distro are BeanShell, Jython and Groovy.

I was using Jython quite a bit in JPublish however I switched to BeanShell for practical reasons: first while I had few problems switching back and forth between Python and Java syntax (occasionally leaving out a semi-colon in Java) other developers I was working with had a harder time. Secondly the classloading in Python was being a bit of a pain in the tail (so much so that JPublish 3.x includes a JythonScriptHandler specifically designed to massage the Jython sys path a bit. Ultimately though it was just the context switching (from Python to Java and back) which resulted in the switch to BeanShell.

I haven’t really done much with Groovy yet, I just added some code to JPublish to make it available using BSF, so I will not pass judgement on whether or not it will suffer from the same context switching, however I believe that it will if the code is written in the Groovy style of coding (which I wager will end up looking more like Python than like Java).

Posted by: Anthony Eden at May 11, 2004 @ 10:37 am

4. Webwork…WW2 (MVC Framework) + Velocity and SiteMesh (View Layer) + Spring (Service Layer ?) + iBATIS/DBCP or Hibernate/DBCP (Persistence) + MySQL/Oracle (Data Layer)

Keep spring just for ioc and transactions. Its web framework is still too http-ish like struts. I love how xwork actions are just any no arg methods that returns a string.

Posted by: Matthew Payne at May 11, 2004 @ 10:39 am

Matt: Could not agree more. Yes, that’s what I plan to use Spring for. Will post my app once I am done. Do you have an app in mind that I can refer to (which already uses this framework set and is open-source)? Thx for the comment.

Posted by: Anand Sharma at May 11, 2004 @ 6:46 pm

Anthony: Thx for the clarifications. Will definitely try to take JPublish for a ride when I have some time.

Posted by: Anand Sharma at May 11, 2004 @ 6:47 pm

Anand: Just a little comment, RIFE allows you to implement your actions (elements in RIFE) in BSF languages too and currently ships with Beanshell, Jython, Groovy, Pnuts, Rhino, Jacl and JRuby.
When it’s possible it doesn’t even use BSF, but directly interacts with the scripting language interface instead (like with Groovy). This allows you to write more versalite code in the scripting language (ie. a complete class instead of just a method).
Additionally, you can write them in plain Java and if your compiler hasn’t compiled them before, the framework automatically compiles and recompiles/replaces them from Java source code. Apart from the little compilation delay (very minimal with Jikes), this gives some of the benefits from scripting languages to plain Java since you can just edit and reload the page without restarting anything.

Posted by: Geert Bevin at May 12, 2004 @ 2:27 am

Nice comment Geert. Do you have a blog or a site where we can get some of these nuggets. Or will I have to dig thru my comments to figure things if and when I am ready to play with RIFE..:-)

Posted by: Anand Sharma at May 12, 2004 @ 9:27 am

Anand: http://www.uwyn.com/blog is my blog, you can always sign up to the RIFE mailinglist for help, there’s often someone in the #rife IRC channel on Freenode too, and the wiki (http://rifers.org/wiki) and release notes (https://rife.dev.java.net/servlets/ProjectNewsList) contain quite some invaluable info.
For the rest I suggest you start out with the ready-to-run examples (online demo at http://rifers.org/examples/) and the users guide as said in my initial comment.
We always like hearing about how the experience of new users, so don’t be afraid to drop by at the IRC channel, we’re actually a merry bunch of friends over there ;-)

Posted by: Geert Bevin at May 12, 2004 @ 1:25 pm

Will do Geert. Just not in the next few weeks as I am really swamped with all the stuff that I have to do in my day job. Gotta keep those bills paid after all..;-)

Posted by: Anand Sharma at May 12, 2004 @ 2:31 pm

Dear sir!
Teach me about Java basic programming.I am very interesting it.
I attended here but not clear.
Thanks.

with regards,
Myo Thant

Posted by: Myo Thant at August 7, 2005 @ 2:09 am