Matt RaibleMatt Raible is a writer with a passion for software. Connect with him on LinkedIn.

The Angular Mini-Book The Angular Mini-Book is a guide to getting started with Angular. You'll learn how to develop a bare-bones application, test it, and deploy it. Then you'll move on to adding Bootstrap, Angular Material, continuous integration, and authentication.

Spring Boot is a popular framework for building REST APIs. You'll learn how to integrate Angular with Spring Boot and use security best practices like HTTPS and a content security policy.

For book updates, follow @angular_book on Twitter.

The JHipster Mini-Book The JHipster Mini-Book is a guide to getting started with hip technologies today: Angular, Bootstrap, and Spring Boot. All of these frameworks are wrapped up in an easy-to-use project called JHipster.

This book shows you how to build an app with JHipster, and guides you through the plethora of tools, techniques and options you can use. Furthermore, it explains the UI and API building blocks so you understand the underpinnings of your great application.

For book updates, follow @jhipster-book on Twitter.

10+ YEARS


Over 10 years ago, I wrote my first blog post. Since then, I've authored books, had kids, traveled the world, found Trish and blogged about it all.
You searched this site for "java web frameworks comparison". 2,229 entries found.

You can also try this same search on Google.

The Joy of developing with JSF

I plan to write up a "My JSF Experience" post later today, but first, I'm forced to rant on the state of JSF implementations. First of all, I must say that JSF isn't so bad. It's cool how you can map buttons to "actions" defined in a navigation entry, as well as to call a method in a managed bean. The problem that I'm experiencing is that the JSF implementations, both from Sun and MyFaces - are errrrr, not so good.

I actually managed to almost finish my simple JSF sample app in one day, but then decided to shoot off some questions to see if I could resolve some remaining issues. Then based on feedback I received, I decided to switch from Sun's RI to MyFaces - not only for the "sortable" grid (I still don't know if it exists), but also Spring supports it w/o using an add-on library.

Ever since I switched, things just haven't gone right. First of all, MyFaces, requires your implement a <listener> in web.xml - who knows why, but you get an error indicating you need it if you don't have it. Standard JSF doesn't require this - why does MyFaces?

OK, I can deal with adding the listener. Everything works as with Sun's RI - and even better since the "layout" attribute of <h:messages> actually works. BTW, why isn't "div" a choice instead of "table" - whoever designed these choices obviously still uses Netscape 4 and table-based layouts. I'm happy now. MyFaces seems to solve the duplicate post issue so if you refresh after adding a record, it just shows a blank form. Cool, I can live with that.

One problem I found, that likely exists in both implementations, is that it's a true pain-in-the-ass to get a declared ResourceBundle in a managed-bean. Here's the method I'm currently using to add a success message:

    public void addMessage(String key, String arg) {
        ApplicationFactory factory = (ApplicationFactory)
            FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
        String bundleName = factory.getApplication().getMessageBundle();
        ResourceBundle messages = ResourceBundle.getBundle(bundleName);
        MessageFormat form = new MessageFormat(messages.getString(key));

        String msg = form.format(new Object[]{arg});
        FacesContext.getCurrentInstance().addMessage(null, 
                new FacesMessage(FacesMessage.SEVERITY_INFO, msg, msg));
    }

There has to be an easier way! Please tell me there is. I admit that I'm a JSF rookie - having just started using it two days ago, but it seems ridiculous that all the "success message" examples out there don't even consider i18n.

So now I have my success messages working, but I discover that there's no way to escape HTML (using <h:messages>) from my ResourceBundle (to put bold around a part of the message). ALL of the other MVC frameworks I've been dealing with allow this - why doesn't JSF?! Again, I'm hoping someone tells me I'm ignorant and there is a way to do this.

Lastly, I tried to upgrade to the latest MyFaces snapshot from CVS to solve this bug and now I can't even get my fricken app to start up because of this issue. Are these the hoops that developers have to go through to get started with JSF? Thump, thump, thump. My head is starting to hurt.

Update: I'm an idiot about the "can't get my app to start thing" - I didn't copy all the new myfaces*.jar files into WEB-INF/lib. Heh. =P~

BTW, MyFaces requires a whole slew of JAR files just like Struts. Here's my current inventory:

  commons-codec-1.2.jar
  commons-collections-3.0.jar
  commons-digester-1.5.jar
  commons-validator.jar
  commons-oro.jar
  commons-logging.jar
  jstl.jar
  myfaces.jar
  myfaces-components.jar
  myfaces-jsf-api.jar

Posted in Java at Aug 06 2004, 10:35:05 AM MDT 4 Comments

RE: Why use Maven

Warner has a post about why he likes Maven. He might not know it, but he's actually ripping on AppFuse, its directory structure, and build file. I like getting ripped on, so that doesn't bother me. What bother's me is that Warner has comments turned off so no one can get him back. ;-)

The main reason that AppFuse uses Ant over Maven is speed. Maven runs much slower than Ant. Period. Also, with an open source project like AppFuse - I try to appeal to the larger audience, who likely has Ant installed. Other OS projects I work on (displaytag and struts-menu) both use Maven and people have a lot harder time trying to build from source b/c of Maven issues. Lastly, I like having a complete download - rather than download-dependencies-after-you-download-the-project like Maven does. I realize if I did use Maven I could package the dependencies in the app - which is likely what I'd do anyway since the main repositories seem to be constantly out-of-date.

Recently, I had a similar experience to Warner. As part of my current contract, I was tasked to write a couple of Maven sample apps. Warner came to my rescue and helped me out a lot, but I felt like I was jumping through a lot of hoops to do simple stuff that was already done in the Ant version of my app. I guess I'm just not a Maven guy. A project that's done right, regardless of if it's done with Ant or Maven, should build by typing "ant" or "maven" - or at least provide you help on what you need to type. Some projects, like Spring and Struts, actually allow you to use either one out-of-the-box. That's a pretty cool idea and likely keeps everyone happy.

It sounds like Warner has re-worked AppFuse to work with Maven. Care to donate your couple hours of work? I wouldn't use it personally, but there has been interest in a Maven version. Some folks seem to like slow build tools.

Posted in Java at Aug 04 2004, 03:29:04 PM MDT 26 Comments

JSF: Which implementation should I use?

A few weeks back, Bill Dudney recommended I use MyFaces for my JSF app. He said it was less buggy than Sun's version. When I looked at MyFaces's website today, I noticed all their releases are betas - which is not a good sign IMO. Anyone have experience with either one? I think I'll go with Sun's as it probably has a larger community, and therefore more information.

I'm also hoping to use the JSF-Spring package. I was a little scared when I saw it's lack of documentation, but then I discovered it's in the JavaDocs if you scroll down. I'm not looking forward to the JSF's tag soup, but hopefully it won't be too bad.

Posted in Java at Aug 04 2004, 09:33:16 AM MDT 4 Comments

My Tapestry Experience

I've finished migrating the sample app I'm working on from WebWork to Tapestry. You can also read about my WebWork experience. WebWork took me 2 full days to complete and the Tapestry version took me about 4. I had a bit of an advantage with WebWork as I've read a lot about it before working with it. I'm probably a bit biases against Tapestry because everyone thinks it's the bees knees - I don't mean to be harsh - I'm just reporting through the eyes of a developer. I'm sure I'll have similar gripes with JSF. Below is a list of things I discovered:

  • There's something wrong with a project when its documentation is outdated and folks tell you to "Buy the book" rather than "read the documentation". On that same note, most of the documentation that does exist seems to be targeted at the advanced user.
  • Like WebWork, there was no simple CRUD example I could look at. Then, like a ray of light from the sky - Warner published one yesterday! This tutorial vastly improved my productivity - thanks Warner! The only things I saw that I'd change in this tutorial is the use of individual setters vs. a domain object. Also, an ICallback is in the code, but never really used.
  • The recommended way to name templates (.html) and page specification (.page) files is starting with an Uppercase letter. So rather than home.html (which most web developers are used to), it's recommended you use Home.html. Of course, this is easy to change - just seems like a weird recommendation, almost Apple-ish or Microsoft-ish.
  • By default, all templates and pages are cached. Sure this is good because Tapestry is production-ready, but when you're developing - this needs to be off so you can get deploy+reload functionality. If you're using Tomcat, you can turn caching off by setting a $CATALINA_OPTS environment variable with value "-Dorg.apache.tapestry.disable-caching=true" (no quotes).
  • Tapestry integrates with Spring very nicely. So easy it's almost silly. When I first created my list screen, it actually had only one line: public abstract UserManager getUserManager(); - and then I used OGNL to get my list of users: userManager.users. It doesn't get much easier than that.
  • While setting success messages is fairly easy - I couldn't find a good way to prevent duplicate postings. With most frameworks, I stuff messages in the session and then retrieve them on the next page. With Tapestry, you have to throw a RedirectException if you want a true redirect (which requires a lot to calculate the URL of a page). I ended up using a PageRedirectException in hopes of simplifying this - but this seems to just do a forward instead of a redirect. In the few hours I spent on it, I couldn't find a way to save success messages and have them persist through a redirect. The reason I want to use a redirect is so a refresh of the page doesn't submit everything again. I know it's trivial, but is is an issue that most frameworks don't handle cleanly (except for Struts).
  • There's no way to test Tapestry classes - since they're abstract, you can't just invoke them and test. Granted the classes are simple - but as long as other frameworks allow you to test their .java files and Tapestry doesn't - this will be an issue.
  • When you first enter a blank form (i.e. to add a new user), the cursor's focus is put on the first required field. As a developer and user, I'd like to control this a little more (for example, by putting it on the first field). Furthermore, I'd like to control it easily - without having to subclass ValidationDelegate. On that same note, it'd be cool if required fields had an asterisk by default. WebWork does this and Spring/Struts can do this using Hatcher's LabelTag.
  • There's no easy way to get the URL of a page - for example, to use in a <button>'s onclick handler to do location.href. I ended up having to implement a method in my page class, and a @Block in my template, setting the button's value with OGNL, and then using JavaScript to do onclick="location.href=this.value". The default components that ship with Tapestry only produce links and submit buttons (that must be in a form).

When developing this sample app, I often felt like I was banging my head against the wall. This is likely because I didn't want to take the time to truly understand how Tapestry works - I just wanted to get my app done. I did end up buying Tapestry in Action, but I probably won't read it until I have time or decide to use Tapestry on a project. I agree that Tapestry is cool, but it's certainly not intuitive for a Struts guy like me. I do look forward to working with it in the future and I'm sure I'll grow to like it more as I gain more experience.

Many thanks to Erik for his tech support and knowledge and to Warner for his nice kickstart tutorial.

Posted in Java at Aug 03 2004, 04:39:42 PM MDT 6 Comments

AppFuse Changes: Unit Testing with Easy Mock and Spring's Struts Plugin

I have a couple of proposal for the next AppFuse release. Let me know what you think:

  • Change service and action/controller tests to use Easy Mock to mock dependencies. This will likely require a bit more code in the test, but it'll allow true unit testing of components. Current tests are more like integrations tests, which tend to be slower. The Canoo WebTests will continue to act as the integration tests that verify functionality top-to-bottom.
  • Change Struts to use Spring's Struts Plugin. XDoclet's Spring stuff should make this pretty easy so you don't have to modify any XML - just like the current situation. The advantage of this is you can use dependency injection on your actions, rather than getBean(...).

I hope to get these in, along with a WebWork option, in the 1.6 release. I'd love to get 1.6 done and released in August, but I'm probably dreaming since I'd like to finish Spring Live in the same time frame. Of course, I'm also planning on fixing any bugs that are currently entered.

Posted in Java at Aug 02 2004, 11:34:21 AM MDT 12 Comments

23"

23 Incher

I arrived home this afternoon and found that my new 23" monitor had arrived. This thing is fricken' awesome! It's so crisp, clear and BIG!! The only bad part is that I thought it supported Windows out-of-the-box - by having a VGA port. No such luck. It looks like I'll have to buy a DVI male to VGA male adapter - or possible new DVI video cards. New video cards would suck since I'd have to buy 3 for my two Linux boxes (Fedora and Suse) and one for my Windows box.

Regardless, it plugs right into my PowerBook and works great with it.

Posted in Mac OS X at Aug 01 2004, 08:44:03 PM MDT 8 Comments

Pretty URLs in Tapestry

It looks like Tapestry 3.1 will have pretty URLs - which will make it much easier to use CMA. Identity Theft 911 has recently converted their 300+ page website from JSP to Tapestry. If you click through the site, you'll notice that the URLs what you'd expect to see, rather than Tapestry's ugly URLs. The best part is they explain how they did it, and Howard loves it:

Wow! You've prototyped Tapestry 3.1 for me :-) Only had a chance to look at the home page (I'm at a client) but it does look sweet.

Posted in Java at Jul 29 2004, 01:27:42 PM MDT 7 Comments

Moblogger re-written with Spring

About a month ago, someone sent me a re-write of Moblogger that was done using Spring. The other night I cleaned out my inbox (select all, delete) and then realized yesterday that I'd deleted the e-mail the guy had sent me. If you're out there and reading this blog - please send it again, leave a comment, or shoot me an e-mail. I'd love to use your code in place of what's already there.

Posted in Java at Jul 28 2004, 12:12:24 PM MDT Add a Comment

Get your designs for free

From Niel:

While I'm confident in my web-based application development skills, I really suck at web design. Fortunately there is Open Source Web Design which provides hundreds of web designs to help people like me. Most of the recent entries are CSS-based designs that show-off the power of CSS.

I suck at web design too, so I dig sites like this. The CSS Zen Garden is another great resource. Their designes are free for non-commercial use. If you contact the designers, you might get permission to use them like I did.

Posted in The Web at Jul 27 2004, 04:01:01 AM MDT 2 Comments

Eclipse Tips

From my Eclipse HowTo for Spring Live:

TIP: In order to clean up the project view in Eclipse, you can hide the files you don't need. First of all, make sure you're in the Java Perspective (Window → Open Perspective). Then click the little (down) arrow in the top right corner of the Package Explorer pane. Select Filters, check the "Name Filter Patterns" and type "*.jar" (no quotes) in the text field. Then in the list of elements, scroll down and check Referenced Libraries. Click OK to continue.

Another useful Eclipse trick is to use abbreviated package names. You probably won't need it on this project, but its nice on projects where you're inflicted with super.long.package.name.syndrome. Go to Window → Preferences → Java → Appearance. Check the "Compress all package names" checkbox and type "1." (no quotes) in the text field.

Want more tips? Ask Bill.

Posted in Java at Jul 23 2004, 04:02:39 PM MDT 16 Comments