Matt RaibleMatt Raible is a Web Developer and Java Champion. 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.

Down on Struts?

This post on Why are people so down on Struts probably deserves an immediate rebuttle, but I'm too tired and have better things to do. The best reason I can say that I like it - it's paying the bills. Show me a better framework and a contract that wants to use it, and I'll be all over it like a monkey f**in' a football. ;-)

So you ask, what "better things" do you have to do. Well, there are many things better than pounding on this keyboard (i.e. playing with Abbie, loving my wife), however, I'm a sad sob and I'll be here all night. I'm planning on digging into struts-menu and 1) upgrading it to CoolMenus4 and 2) configuring it to allow lists for DHTML menus. Then I have to make sure both methods allow for permission checking, since I want to use struts-menu to display url-hiding security in my chapter. Wish me luck - and feel free to help if you want to get your hands dirty!

Posted in Java at Dec 06 2002, 01:40:17 PM MST 1 Comment

Webapp Configuration

Jeff Duska has a post tonight on how he handles app-specific configuration settings. His method sounds pretty neat, and hopefully we can combine our methods to come up with a better solution. Here's how I've been doing it.

  1. I have a StartupServlet that reads in an XML file and, using Castor, populates a JavaBean with the XML file's values. Sidenote - I recommend having a StartupServlet in webapps to populate drop-down choices from the database and stuff ArrayLists (of beans) into the ServletContext - works real slick in Struts using the LabelValueBean.
  2. Stuff the JavaBean into the servlet context and get values as needed while running the app.

Jeff's method seems make it easier to retrieve the values, but not to set them. I have a getConfiguration() method in my BaseAction class that I use to get my configuration data:

/**
 * Get the Configuration object from the servlet context
 */
public Configuration getConfiguration(){
    return (Configuration) servlet.getServletContext().getAttribute(
                   Constants.CONFIGURATION);
}

The obvious problem with this is that only subclasses of BaseAction can get the configuration information - therefore, I like Jeff's idea better. However, I'm curious to know how he populates his Registry class. Castor makes it pretty damn easy. Here's the method I use in StartupServlet, where obj is my JavaBean, and xmlFilePath is configured as "/WEB-INF/app-config.xml" in one of StartupServlet's init-parameters.

/**
 * Load our application configuration XML file.
 *
 * @exception Exception if any problem occurs while loading
 */
private synchronized Object loadConfig 
    (
    Object obj, 
    String xmlFilePath
    ) 
throws Exception {

    // attempt to extract the filename, using system file separator
    int index = xmlFilePath.lastIndexOf(Constants.FILE_SEP);

    // no system file separator found in configuration setting
    if (index == -1) {
        // check traditional file separator as used in web app URI's
        index = xmlFilePath.lastIndexOf("/");
        // still no separator, maybe they're just specifying the filename
        if (index == -1) {
            index = 0;
        }
    }

    String xmlFileName = 
        xmlFilePath.substring(index + 1, xmlFilePath.length());
    if (logger.isDebugEnabled()) {
        logger.debug("Looking for '" + xmlFileName + "' in "
                 + Constants.USER_HOME);
    }

    // Acquire an input stream to our configuration file
    InputStream is = null;
    try {
        is = new FileInputStream(Constants.USER_HOME + xmlFileName);
    } catch (FileNotFoundException fnf) {
    
        // No file found in user.home
        if (logger.isDebugEnabled()) {
            logger.debug("File not found at " + Constants.USER_HOME
                + xmlFileName + " - looking at specified path in web.xml.");
        }
        
        // Look for config.xml in WEB-INF
        is = getServletContext().getResourceAsStream(xmlFilePath);
        if (is == null) {
            throw new Exception("Configuration file '"
                + xmlFileName + "' not found in '"
                + Constants.USER_HOME + "', nor at '" + xmlFilePath + "'");
        }
    }

    InputStreamReader reader = new InputStreamReader(is);
    
    // Marshal the configuration object
    obj = Unmarshaller.unmarshal(obj.getClass(), reader);

    // close the InputStream, and the reader
    is.close();
    reader.close();
       
    return obj;
}

I like this method because it can load multiple configuration files, and I already have it written - so the hard part is over ;-) It also makes it easy to configure your app outside of WEB-INF, and changes won't be overwritten when a user upgrades their WAR file or whatnot. I suppose I could use Jeff's method and make my JavaBean into a Singleton and not store it in ServletContext - that'll probably work better than my current scenario.

Posted in Java at Dec 06 2002, 01:24:21 PM MST Add a Comment

AppFuse and Resume App

I've decided to rename struts-xdoclet to AppFuse! Why? Because 1) it's easier to say, 2) it's a more descriptive name, and 3) it's the fuse to get your app started! I'll be checking it into SourceForge's Struts project soon, and will post more information then.

I've been thinking about my sample app for the Struts Chapter and I'd like to develop something that's useful. I doubt I'll have the time to pull it off, but I'd like to develop a resume builder/viewer app. I think it'd be a great way to demonstrate CRUD with Struts with skills and such. It could even be an application that would support multiple users, where skills can be shared and selected. I've been thinking about doing something like this for a while. It's a pain to update my resume right now because there's 4 different versions - online JSP, downloadable HTML, Word and Text. I've often thought about just creating an XML version and using JSTL to to XSL transformations into HTML, Text, RTF and PDF. I wonder if this XML resume project at SourceForge could help? I'd love to create an app that allows you to easily update your resume and can publish it in all these different formats. Even better, if it could be resume-standards-compliant (i.e. DTD or XSD) and allow users to select/upload/use different styles. I think this would take much of the headache out of online resume publishing. However, I'd probably spend more time tweaking it than I would just updating the 4 different versions of my resume. It'd kinda like this website, I chose to use Roller as my re-design engine because it was quick and easy - and now I spend a couple hours each day tweaking and updating. I could've redesigned for a lot cheaper! Of course, new content == hits.

The only problems I can foresee with this app (so far) are Old Man Time and that it might be a maintenance nightmare. I would suspect a lot of folks might want import/export to/from existing formats. Thoughts? Comments?

Posted in Java at Dec 06 2002, 09:57:52 AM MST 3 Comments

Form-based auth - getting the original URL

Lance suggested a while back that I try Roller's BreadCrumbFilter to get the originally requested URL for form-based authentication. The idea is that if you can get this URL, you can use it to login again on your form-login-error page. So I added BreadCrumbFilter.java to my security project and mapped it to /*. The value I'm hoping to grab is a URL to welcome.do, since that is where I route users when the hit the welcome page. I found that this filter never gives me welcome.do, but that request.getHeader("referer"); gives it to me just fine - but only in IE. Yeck. I guess Craig was right when he said that you can't reliably get the original URL. I guess you can always just hard-code the action in your form-error-page to go to your main menu. That is, if your app server doesn't support the same page thing.

Posted in General at Dec 06 2002, 09:46:18 AM MST 3 Comments

OS X and Writing/Coding

I've been using my G4 Powerbook all week to write this security chapter. Today I started coding and writing at the same time. This post is meant to vent that this laptop/OS is a DOG! It's so fricken slow! I have Eclipse, Word, Mail, Terminal and Internet Explorer running and I feel like I've lost hours for these apps to respond. The machine is 667Mhz and has a gig of RAM! What the hell?! I'll be coding working on my Windows box for the rest of this project, I'm tired of waiting.

Posted in Mac OS X at Dec 06 2002, 08:01:39 AM MST 6 Comments

512MB CompactFlash Cards for $132

Gizmodo tells us about another sweet deal today.

Viking 512MB CompactFlash memory cards are now just $131.44 after rebate at Amazon. Remember when these used to cost hundreds and hundreds of dollars?

What a bargain! Why would you shop anywhere else when Amazon has all these sweet deals lately!? The best part is I'm actually in the market for a new CF card. Our Canon PowerShot G2 (which I highly recommend) came with a 32MB card, which holds about 26 photos or so. With a 512MB card, you could probably take ~400 photos - now that's a role of film! We're hoping to get a Photo Printer soon (I've been looking at Canon's s900), then we'll never have to get our film developed again!

Posted in General at Dec 06 2002, 06:25:01 AM MST 2 Comments