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". 1,588 entries found.

You can also try this same search on Google.

XML Encryption/Decryption

Erik gives us the heads up on a new W3C Proposal: an XML Encryption, Decription Standards. Just after I finished my first draft of my chapter on Security!! Arghh! Oh well, I'm sure there will be a 2nd and 3rd draft. I'll have to read this article and see if it's relevant. The first draft was due Sunday, I turned it in yesterday. It is supposed to include a sample application, and I'm still working on it.

I was up until 5 a.m. this morning working on it. I got Hibernate working nicely, and I can generate my Hibernate persistence layer and my Struts (validator) forms using xdoclet. Cool stuff, I did have to write the business tier to talk to hibernate, and I did have to write a Hibernate class (DAO) to talk to the persistence layer. Not as easy and clean as I'd hoped for, but now that the groundwork is laid, it'll probably be easier to move forward. It's pretty sweet that I can add a getter/setter to my POJO (actually it's an entity bean since that's the only way to generate struts forms using xdoclet) and I get a new column in the database and in both my VO (hibernate uses this) and my Form.

Posted in Java at Dec 10 2002, 09:14:51 AM MST Add a Comment

Caching for Struts

An interesting new extension came through the struts-dev mailing list today. It's called the "neteye actioncache" and is an extension that provides a simple but powerful caching facility for struts. It's features as are:

  • Caching of binary and character data
  • Support for URL based session tracking
  • Allows to use multiple actions on a single page
  • LRU caching policy
  • Persistence

Pretty cool - don't know if I'll ever need it, but nice to know it exists. More information can be found at http://actioncache.neteye.de.

Posted in Java at Dec 10 2002, 08:40:04 AM MST Add a Comment

Struts Menu - Improved!

Well after working until 4 in the morning last night and most of the day today - I'm happy to say that I've completed my desired changes on Struts Menu. I've been talking with the inventor, Scott Sayles, and hopefully I can get these changes committed in the next day or so. The biggest improvements I made were adding new Displayers - one for CoolMenus (CoolMenu4) and one for DHTML Lists (ListMenu). I also added support for a roles attribute (comma-delimited) that will hide menus when users are not in that role. Of course, you will have to use container-managed security for that to work, but it's easy - right? I'm thinking we should probably add a denyRoles attribute as well, as its a pain to add 5 roles just to exclude 1.

The problems I ran into with CoolMenus4 seem to be CSS related, and the Dropdown DHTML List is a little funky when you have too many nested items. Please feel free to dig in and fix these -> should be easy using good ol' view-source copying some files locally if you like. I can also post the source if you'd like, but I think you're more interested in just a demo.

Click here for a demo (expires on 12-15-02), or download the source.

The coolest thing about this bad-ass menuing system is that you can choose a new type of menu just by changing your JSP. Of course, a little magic and you can do it based on request variables or something of the sort. Check out the permissions page for an example.

The sweetest improvement I can think of is to now make the menu-config.xml file editable through a browser - and it'll save the results for you. Even sweeter - if you're really nuts - have this UI talk to struts-config and allow you to select forwards for locations! I could dig in and work on this thing for a week - but alas, I have a chapter to write! Too bad I'm only halfway done and it's due tomorrow :-( Oh well, at least the chapter will demonstrate some good code!

Posted in Java at Dec 07 2002, 10:28:21 AM MST 2 Comments

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

Best OSS License?

I've gotten approval from Wrox to use struts-xdoclet as my sample app for my chapters on Security and Struts. I've also received committer rights from Ted Husted on the Struts project at SourceForge. I haven't checked anything in yet, because I still don't have a good name. While I think struts-xdoclet is a good descriptive name, it doesn't have the pizzazz I'm looking for. So the naming discussion continues. I'm thinking of actually leaving "Struts" out of the name as it seems to make other names more difficult when combined. I like the idea of kindling, which we use to start fires at the cabin, but I don't know if that makes a good app name.

Back to the point of this post, what are your recommendations for a good open source license? I don't really care how people use struts-xdoclet, so do I even need to license it? What happens if I don't include a license?

Posted in Java at Dec 04 2002, 08:29:12 AM MST 5 Comments

Struts WML Tag Library

A Struts WML Tag Library has been posted to the struts-dev mailing list. It's a "pre-release", which means the project is probably not stable, but I'm guessing the technology and tags are.

Struts-wml taglib, 'raw prerelease' is available here:

http://sourceforge.net/projects/struts-wml/

Here's the release notes:

This is a fully functional 'prerelease' which includes source code, sample application, documentation, binary and libraries. It's still somewhat unpolished (therefore raw prerelease). If you're willing to hack arround with it a little bit, you're welcome to download it. Please don't forget to contribute your changes back to the project! [Full Post]

Now it's your responsibility to get a WML project that you can implement this on!

Posted in Java at Dec 04 2002, 01:14:42 AM MST 1 Comment

Day 1 of Writing

I spent most of the day today in the library, pounding away on my keyboard trying to get a good start on my first chapter, Security in Web Applications. I put together suggested outlines for my two chapters over the weekend, and I'm posting them here for your review. I tried to convert them to PDF, but then decided to leave them as Word documents so you can 1) see the outline view, and 2) comment in-line if you'd like. I'll also post the PDF version (thanks to FastPDF).

It was difficult getting started today, but once I got moving, I found that the words just kinda flowed out and it was rather enjoyable. The bad news is that I have until Friday to complete some 40-odd pages and I'm going skiing tomorrow with Julie's uncle, Chris Voda. Actually, the skiing is the good part, it'll clear my head and get me ready to write like a coder in the zone.

Posted in Java at Dec 02 2002, 05:12:29 PM MST 4 Comments

Erik's Struts/XDoclet example application

Erik Hatcher has released his "much hyped and long awaited sample application" demonstrating how to generate some Struts goodness with XDoclet. You'll be happy to know that I've been swapping e-mails with Erik a lot in the past couple weeks - so my struts-xdoclet app is very similar. Here are the details:

It is a trimmed down version of the application Steve and I developed
for our Java Development with Ant book.

Relevant to Struts folks are these tidbits:

  - XDoclet is generating struts-config.xml, validation.xml, web.xml, 
and antbook.tld

  - LabelTag (currently mysteriously busted for required tagging) is 
included.  This tag styles field labels differently if its in error, and 
(when its not busted, it works on my production app actually) it shows 
an asterisk by required fields.

  - strutsgen: a one-off starter generation for JSP's and 
ApplicationResources.properties snippets for cutting and pasting into 
the main application.  It uses XDoclet to process a specified form bean 
and uses the fields it finds for generation.

  - Use of StrutsTestCase for Cactus testing.

  - Maybe some other Struts goodies lurking there that I've forgotten to 
mention.

The application itself is a document search engine, based on Lucene, and 
should run out of the box in Tomcat or JBoss.  It even has the ability 
to (at build time) toggle between whether to use a session bean or not 
(functionality is the same either way).  By default, you can simply 
deploy the WAR that you've built and it will work without EJB, but if 
you are interested in exploring the session bean piece it can be turned on.

I am in the process of creating much more detailed documentation, but I 
wanted to get this out sooner rather than later.  If you find any 
problems or have any questions, please do not hesitate to let me know so 
I can refine it and post updates.

The one documentation I need to provide now is to note that you'll need 
j2ee.jar to build.  I include all other API's.  To build, unzip the file 
(link below) and it will expand into JavaDevWithAnt directory.  In that 
directory, run Ant.  If you have J2EE_HOME set you shouldn't need to do 
anything... just "ant".  You'll also need to build a site index, so run 
"ant build-site-index".  This is intentionally two separate steps.  If 
you don't have J2EE_HOME set, then you need to provide j2ee.jar to the 
build.  Do it this way:

	ant -Dj2ee.jar=/path/to/my/j2ee.jar

Where "/path/to/my/j2ee.jar" is the actual path to your j2ee.jar

Post any questions/problems to me directly.  E-mail me at 
[email protected].

Download: http://www.ehatchersolutions.com/downloads/

You will need JUnit 3.8(.1) as I take advantage of the new lack of 
required String-arg constructors.  junit.jar should live in 
ANT_HOME/lib.  Ant 1.5(.1) is required also.

There will be updates in the next week or so as I polish the 
documentation and address any issues that turn up.

	Erik

Posted in Java at Dec 02 2002, 04:25:10 AM MST Add a Comment