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 "struts". 659 entries found.

You can also try this same search on Google.

Copying Properties: The Good, the Bad and the Ugly

I realize that having an ActionForm and a POJO with the same getters/setters is ridiculous, but please bear with me for this example. I have a Form and a POJO with Strings, Longs and Dates. The Longs and the Dates get converted into Strings when I get the data from the database using BeanUtils.copyProperties. This works great.

BeanUtils.copyProperties(userForm, user);

However, when going back, it's a different story - here's the ugly way:

SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");

Date dateChanged = format.parse(userForm.getDateChanged());
Date dateCreated = format.parse(userForm.getDateCreated());

user = new User(userForm.getUserId(), userForm.getPassword(), 
                Long.valueOf(userForm.getDesktopId()),
                Long.valueOf(userForm.getCubeId()), 
                userForm.getCreatedBy(), dateCreated,
		userForm.getChangedBy(), dateChanged);

While this works, it's ugly and a pain. I want something like the ActionForm-Value Object mapper. This mapper allows you to easily copy properties between VOs (or Hibernate Objects) and Forms, and vise-versa.

vo = FormToVOMapper.map(form, new ExampleVO());

So I could do something as simple as user = FormToVOMapper.map(userForm, new User()); I like this mapper and I used it on my last project, where it works great. However, I get the feeling that developers in the Struts Community are using something better - and I want to use it. So please, tell me what it is and lets figure out the best way to do this. Another method I've used in the past is to set the VO (or object) on the form itself, allowing for setting of Strings without copying - and setting dates on the form, to be manipulated by the setter. This framework worked great, and I was actually the happiest with it out of any of the above. Chime in and give me your opinions!

Posted in Java at Dec 27 2002, 03:14:29 PM MST 6 Comments

ChainedExceptions and BeanUtils.copyProperties

I am wondering about a few things, so thought I'd try and get some help from the best source I know - the java.blogs community. First, an update on last night. I experienced some difficulty with Hibernate (persisting child objects) and Struts (nightly build doesn't quite work right with Tiles and Modules) and gave up at 2:00 a.m. Luckily, my head cleared up this morning after a deep 4 hours of sleep and I figured out Hibernate and it appears that a fix for the Tiles/Modules problem was checked into CVS by Cedric.

Now I'm wondering if it's possible to use declared exceptions in Struts to grab all your Exceptions from the bottom up. I can do this in an Action (or even a filter) using the following:

// caught exception e
ActionErrors errors = new ActionErrors();
errors.add(ActionErrors.GLOBAL_ERROR,
           new ActionError("errors.general"));

while (e != null) {
    errors.add(ActionErrors.GLOBAL_ERROR,
               new ActionError("errors.detail", e.getMessage()));
    e = (Exception) e.getCause();
}

request.setAttribute(Globals.ERROR_KEY, errors);

Can I do this with declared exceptions? Man that would be sweet if I could - I wouldn't have to have any exception handling in my Actions. Maybe that's the easy way out, but it also makes for rapid development - and you can always add them in when you really want them. Two other things I need to do.

  • I have a java.util.Set on my User (Hibernate) object. This refers to a collection of Resume objects. When I generate my StrutsForms, I need to do something in my XDoclet template to turn a java.util.Set into a java.util.ArrayList. I don't know that I have to do this, but I've always used ArrayLists or Vectors on ActionForms for child objects.
  • I am using BeanUtils.copyProperties in a Business Delegate to transfer properties from my User object to a UserForm object. When I do this, the child objects come through as Resume objects - where I really want them to come through as ResumeForms. Is this possible using BeanUtils, or do I have to do this manually?

I should probably do some research now to try and figure this stuff out on my own - but hopefully an answer will come through while I'm doing that ;-). I'll post to the proper mailing lists if I can't figure it out by COB. BTW, if you're using Hibernate, the FAQ is awesome. I wish more OSS (or closed-source software) had documentation this good.

Posted in Java at Dec 27 2002, 11:40:40 AM MST 9 Comments

Will this be an all-nighter?

I'm making a big push to finish the Struts Chapter tonight. Moreover - to finish the sample application. Things are going well so far. I hope it's not an all nighter, but as soon as I'm satisfied with the application, I'll have to deal with proof-reading the chapter, which could be a real headache. On the last chapter, the proof-reading took me an entire day. Ugh.

I just wanna get this darn thing done so I can spend some time with my family again, so I don't have to work weekends, and I can quit (pretty much) working for free. I think the time spent on the sample app will pay off in the long run, as it's already making it easier to develop the application at my new job. I was able to install, compile, deploy and start authenticating/pulling information from Oracle in a matter of hours. That's taken weeks in previous gigs. Of course, if you count the slow machine I had, the meetings and the installation of new software (trying to get the machine setup), then it probably took a week.

I took my home-built machine into work this morning - and all was peachy until I asked the help desk to add my computer to the domain. Politics came into play and I was told that the technicians have to build the machines, not some dev-head. No biggie, just get me a faster machine I said. I argued with the guy for a bit as I tried to explain that a 700 Mhz, 128 MB RAM machine was too slow for Java Development. When he said that was one of the fastest machines they had, I almost choked. Luckily, they found a 2 Ghz machine that I get to start using tomorrow - this'll be the 3rd machine I've built since I started last week. Damn. Sure is nice working from home when you have everything setup already. Do you think that tele-commuting will be the wave of the future? The clients that've paid me to work from home are getting a heckuva better deal than the ones that require an on-site consultant.

Posted in Java at Dec 26 2002, 05:01:44 PM MST Add a Comment

Hibernate Reverse Engineering Tool

Thanks for all the tips for setting my proxy/port for Java apps. Now I just have to try to figure out what the proxy server/port is. I tried to get it yesterday, but everyone only seemed to know the automatic configuration URL. I'm hoping that's a text file with some information in it that I can use.

Jon Lipsky also hooked me up (via e-mail) with the Reverse Engineering Tool for Hibernate. If I get a chance to use it today - I'll report on it's ease of use, etc. I wonder if I can generate my classes, mark them up with XDoclet and then produce my Struts ActionForms. Or possibly, I can generate the classes with Hibernate and create my ValidatorForms by hand. It'd be cool if the Reverse Engineering Tool supported generating an XDoclet-ready class, and also allowed for regeneration. I probably shouldn't be hoping for too much - it might just work as is.

Posted in Java at Dec 20 2002, 12:23:52 AM MST 3 Comments

Erik Hatcher's Blog

I saw it a couple weeks ago, but now Erik appears to be updating it regularly. Just in case you didn't know - you can find it here. Erik is an Ant Guru and has written many cool Struts extensions (i.e. LookupDispatchAction, XDoclet integration). He's made my life a lot easier with his Ant wisdom and Struts goodies - thanks Erik.

Posted in Java at Dec 18 2002, 01:17:30 AM MST 1 Comment

Eclipse Plug-ins for Struts and DAO Generation

I ran across STRECL.COM today via the struts-user mailing list.

TRECL is a set of plugins for the Eclipse IDE. Using STRECL you will get a powerful tool for Java server-side applications development. STRECL plugins offer easier utilization of the Struts framework in Eclipse IDE by visualization of editing, facilitating navigation, wizards etc.

STRECL currently offers the following plugins:
  • struts-config.xml editor
  • JSP editor
  • DAO generator
  • validation.xml editor
  • Struts navigator view

Just in time to get some coverage in my Struts chapter - that is, if it's any good ;-)

Posted in Java at Dec 17 2002, 05:52:00 AM MST 3 Comments

Bloody Noses and Struts Chapter Progress

I've gotten three bloody noses in the last 36 hours - and I don't seem to recall ever having them before in my life! Yikes - is the stress getting to me?! Oh well, I'm sure I'll be fine. I read on a website today that bloody noses are way over-emphasized and they aren't a big deal at all.

I'm at 22 pages on the Struts chapter now, doing Exceptions and how Struts lets you declare exceptions in your struts-config.xml -- pretty cool stuff. The bad part is that I've never used them before, so it's kinda tough to write about them - at least in the context of Struts. I tried to use Strut's ApplicationException (now renamed ModuleException) last summer on a client's project - and it was too buggy to use. Now it seems to to work as I originally expected it to, and it's pretty sweet. I do feel like I'm building an application to show functionality though, rather than developing an application to fulfill some requirements, which is unfortunate. I'd rather build an application that employs KISS, and shows the easy way to do things. It's like using design patterns because your manager thinks they're a good idea, but you could get the project done in half the time without them. Sure, your app might not be extendable in the future, but if it doesn't live past 3 months, what's the point?! Of course, I think using the Validator and Tiles is easy, and many developers think that's the complicated part. If my learning curve was up to snuff, Exception and Modules (a.k.a sub-applications) would be easy. Soon they will be, though I still may never use them.

Tomorrow is my last day (for a while) as a full-time employee of Raible Designs. I've certainly enjoyed the last year, but I've missed the office comradery and face-to-face interaction. It'll be good to get back into an office, but I'm sure I'll miss coding in my living room within a week, and wish I was back here.

I'm going to get my mugshot tomorrow for the Wrox book - I've convinced Abbie and Julie to go with me so we can get some good family photos - should be fun. After that, I'm going to fill out the paperwork - W2's - for the new gig, and then off to a project kick-off party! Sounds like my kind of project already!! It's got a good name too - Project Fiji. One of the things I'm looking forward to is implementing Struts and Hibernate (if they'll let me) using XDoclet. I've done it in my sample project and AppFuse (expect a new release in a week), but it'll be awesome to cut our development time in half right away! Especially when the first deliverable is due January 15th!

If I'm good (and I can figure it out), I hope to use Maven on the project as well. It should be interesting to be the primary Java Developer on the project, along with a Web Developer and Oracle DBA. I've always been the web developer - but I've learned so much in the past year and a half (since I met Struts), that I feel more than comfortable being the Java guy. You know what the best part is - I feel like I've learned more from the java.blogs community than I have from studying for certifications, or from any conferences I've been to. Keep it up - learning is awesome!

You know what the better part is? Julie just said to me - "thanks for making all my dreams come true." Enough said, life is awesome - even with toilet paper stuffed up my nose and a chapter that seems like it'll never get done.

Posted in Java at Dec 16 2002, 03:56:38 PM MST 1 Comment

Commons Validator 1.0.1 Released

This release contains only bug fixes - there are no new features in this release. You can download the binary or source distributions, or simply checkout the Validator web site. I expect that will be included with tonight's nightly build of Struts.

Posted in Java at Dec 15 2002, 05:14:43 PM MST Add a Comment

RE: Struts? WebWork? Tapestry? Cocoon?

Aslak tipped me off about Anthony's Wafer research project. There I found the feature matrix of all the web application frameworks they've looked at. I don't know when this matrix was last updated, but I question a few of the entries for Struts. In particular:

  • Template Languages - it supports Velocity and XML
  • Security - it supports adding a role attribute to your action-mappings to secure servlets, as well as roles in Tiles, Struts-Menu and the logic:present tag library to limit access when using container-managed security. I'm guessing that they mean a different type of security here.
  • Documentation - Apache doesn't host an online demo, but I've seen many, for instance my strutscx demo [strutscx home]. There's also the stxx project. I'm guessing the development team has to host one to fit the satisfy the requirement here. It does have a number of tutorials though, including my favorite Strut By Strut. Example code is all over the place, O'Reilly has been pumping out a lot of it lately.
  • IDE Integration - Easy Struts and the Struts Console.
  • WAP/WML - The Struts WML Tag Library.

I hope this helps to boost Struts' credibility on this matrix. I'm off to Barnes and Nobles to write some more on Tiles and Exception Handling with Struts. It's open 9-11 everyday and all the local libraries closed at 5 today. I'm about halfway through the chapter (page 15). Tomorrow will be fun-filled with a full day at the library and hopefully I will finish. Then an all-nighter (maybe? I hope not) on Monday night to proofread, and then send on Tuesday. I doubt I can get my struts-resume app done by Tuesday night, so I'll probably turn that in later in the week. Although, using XDoclet, Hibernate and Erik's StrutsGen tool, I might just be able to pump the whole app out in a couple of hours!

Posted in Java at Dec 15 2002, 02:33:37 PM MST Add a Comment

Tomcat Deployment App

On of my clients has asked me to setup a deployment app. Basically, we have seven instances of tomcat setup through one Apache webserver. Apache proxies to each instance based on different domain name. They want the ability to upgrade each instance with the click of a button. Here's my idea:

  • Create a Struts-based app that allows file upload, where they can upload a war file.
  • Part of the file-upload process is selecting which servers they'd like to upgrade.
  • Based on the server names, the war file is copied and expanded in the tomcat/webapps/appname directory for each server.

Will this work, and can I do this through a webapp? It'd be cool to do steps 1 and 2 with a webapp and have step 3 run by Ant. Is it possible for a webapp to call Ant? The second piece that they're probably going to want is the ability to setup these virtual slices on the fly, from a web page as well. That might be a little tougher, as it would involve: editing http.conf/workers.properties, creating a new user for the slice, copying/expanding a base Tomcat install, editing the server.xml for new ports, creating a new MySQL instance for the slice, and finally, creating startup scripts. Yeah, I might have to pass on creating that app - probably not logical to do it from a webapp. Especially when it only takes about 10 minutes to setup right now.

Posted in Java at Dec 15 2002, 07:17:58 AM MST 4 Comments