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

You can also try this same search on Google.

Struts Training: Week 3

I just signed in for 3rd week here in Struts Training. I'm coming to you live from Chelan, WA. So on with what Ted has to say.

Ted's talking about persistence in Struts: Transaction Script vs. Domain Model.

Transaction Script - organizes business logic by procedure. Great choice for small applications with simple logic. For example, online auction, public search engine or an address book.

Domain Model - an object model of the domain. Has a rich variety of objects that incorporate both data and behavior. Ted mentions that the Domain Model is better for larger applications. For example, managing inventory for an online auction might require using the domain model.

What Ted is doing is using the Domain Model to separate Struts from his Actions - so that he passes around a DomainRequest, DomainResponse, and gets his form from a factory. To me, this looks like a good way to make your Struts layer a lot more complicated! ;-) At the same time, Ted is getting this information from Martin Fowler's Patterns (in Enterprise Architecture, ISBN 0321127420) book, so maybe I should move to the domain model. Naahh, I think I'll keep using the Transaction Script method - it's probably easier for folks to learn and would definitely be easier for rookies to maintain.

Onto Hibernate and how it works:

- POJO beans, encourages fine-grained
- Utilizes "persistence by descriptor"
- Provides DBA-friendly text queries
- Plays well with others
- Buffet-style implementation

IMO, if you're not using Hibernate, you should know why. If you're starting a new project, it's worth looking at. If you're using it, but not using XDoclet - you should be. XDoclet is the best way to avoid DD Hell (quoted from Erik Hatcher).

I didn't know that Hibernate supported a version - did you? Apparently you can specify that a property is a version and Hibernate will use it as you'd expect. Don't see that I have a need for that, but possibly. Would a struts-resume user ever want to keep old versions of their resume? I like to keep old versions of mine, but I have to admit, I never look at them again.

<version name="version" />

Ted just touched on how Hibernate can generate your database schema for you. This is a very powerful feature IMO - especially with struts-resume. It makes it nice for an example app. For instance, with struts-resume, you can run "ant setup-db" and it'll drop tables and re-create your db schema for you.

A student asks about the bottom-up approach - what if you already have a database. My advice? Try looking at Middlegen, its Hibernate Plugin in designed to create an XDoclet-enabled POJO from a database schema. There's also the Reverse Schema Generator that is included with Hibernate. I've used this one and it works great. I've never used Middlegen, but I should be considering that I tag the generated POJO up with XDoclet tags.

Interesting: Ted just mentioned that Gavin (Hibernate's Lead Developer) is working on a book for Manning. It is on Object Relational persistence and it uses Hibernate for its example apps. Erik Hatcher, at his preso on Wednesday, also mentioned that an XDoclet in Action book will be published soon by Manning. He even showed us the book's cover - so I'm assuming it will be published soon.

Hibernate's Fashionable Friends: XDoclet, Commons Logging, Commons DBCP, DynaBeans and Turbine Caching.

To learn more about this Hibernate, checkout:

· AgileData Website (Scott Ambler)
· Hibernate Homepage
· Struts Application Site (Hibernate example and Struts Resume both use Hibernate with Struts)

Vic still likes RowSets and SQL better. I'm guessing this is because he's a SQL expert. The nice thing about Hibernate is that it's query language (HQL) is very much like SQL and allows you to do complex joins. At least, to my knowledge, I've never done any fancy joins in the HQL, just in the mapping (*.hbm.xml) files.

Quote from Ted: This is the year of JUnit books. Watch for them this summer..

Now Ted is covering StrutsTestCase, a JUnit extension that hooks into Struts and Cactus. IMO, it's an awesome way to test Struts Actions - even easier than testing a servlet with Cactus.

Another book: JUnit in Action (Manning) by Vincent Massol and Ted. To be published this summer. Vincent is the lead developer on Cactus, so I expect this to be a great book. Right now, I wish I had written my first book for Manning rather than Wrox. :-(

The one bad part about today's session is that I had to use a calling card to dial in and at $0.35/minute, I'm up to about $25! I should probably sign off soon and save some cash...

Tapestry - are you using it? A student asks about it and Ted mentions that he views it as a presentation framework like Velocity. I've heard lots of good things about it, but have never used it. Ted admits that he uses Velocity and gave up on using JSPs a while ago.

Good stuff - thanks Ted, I'm signing off (the QA session is still in progress).

Posted in Java at Mar 15 2003, 08:37:28 AM MST 1 Comment

Good Humor from the struts-user mailing list

This made me laugh out loud, so I thought I'd share:

Hi, all -- I'm new to struts and I have a few questions. Since you are
the experts I'm sure you will be able to help me.

My boss wants to know how many people are using struts and how long it
will take to build our application using struts as opposed to our current
development process. We currently have a thousand monkeys sitting at a
thousand emacs editors. The application isn't completely designed yet,
and of course I can't release confidential information about our 
application but if you could give me an estimate of monkey-hours saved, 
that would be great.

I was able to download the struts-blank.war file but I am having trouble
setting it up. The first stumbling block was that it is misnamed. It
should be called 'struts-blank.zip' because it is in zip format. I had 
to open the file in hexedit to figure that one out. Hopefully the next 
version will have the right name???

The other problem I have is that I can't get my application to behave
properly. If the user types in their email address I want to be able to
check that it is a correct one and show the field red while they are
typing if it is not. I have a javascript that checks for the '@' sign but 
many people are typing in 'a@a'. Since I don't think so many people would
have the same email address we are losing valuable data. How can struts 
help me with this? Will it take many monkey-hours to implement?

Once I unzipped the file I could not find any README or INSTALL file. I
tried the usual 'make; make install' but that did not work. I went out
on the net to find some install instructions and I read one place that 
said I just had to stick the zip file inside my tom cat. I do have a cat, 
but she's female. Will that make a difference, or does struts only run on
male cats? Does it matter if they are neutered? Does each client need to 
have a male cat or just the server?

Posted in Java at Mar 13 2003, 10:35:55 AM MST 4 Comments

Struts from Scratch

More goodness from the struts-user list this afternoon. In reality, I don't know why I'm posting these as I'm not planning on reading them - maybe in hopes that some of you will find it interesting. Could be that I worked until 3:30 last night and got up again at 7. Red Bull at lunch and I feel like I got a full night's sleep!

Struts from Scratch covers a Struts install from ground zero.

It provides detailed install and configuration steps for a beginning Struts application. It comes with a basic sample application and basic Ant build script (available for download from http://www.strutskickstart.com).

Posted in Java at Mar 11 2003, 12:42:39 PM MST 1 Comment

[ANNOUNCE] Struttin' With Struts beta

Struttin' With Struts Rick Reumann has put together a nice website with tutorials for learning Struts. From the struts-user mailing list:

I created a web site that walks new Struts users step by step through the development of three VERY simple web applications in three lessons. Each lesson adds a few more features so that they build upon each other yet each stands alone such that if you follow the steps in any lesson you'll have built a very basic application regardless of which lesson you start with.

I created these because there seemed to be lacking some more recent "walk through" Struts tutorials geared toward the very new Struts developer. I think real newbies will find them especially useful, but then again I could be way wrong:)

I'm considering the site a "beta" because I'm sure there will be some mistakes. If anyone sees something I'm doing in a lesson that is way off (or a very bad practice) please let me know. Some of the stuff I know could be done in a more "best practice" way, but for the sake of trying to also keep the lessons small and simple some ideas weren't included (ie- I didn't use a constants interface for my forward definitions).

If anyone wants to contribute, reword, or add anything please let me know. The site is there to help others. I got really lazy in a lot of places and didn't say much about certain things that I would have liked to. Hopefully over time the site will improve.

Struttin' with Struts:

http://www.reumann.net/do/struts/main

-- Rick

Thanks Rick - looks very cool! I like the design too - nice work!

Posted in Java at Mar 11 2003, 08:50:58 AM MST Add a Comment

Hibernate Enhancements

For you Hibernate users/lovers, here's some good news for you (THANKS GAVIN!):

1. [Hibernate Forum] For XDoclet users its well-worth grabbing a CVS update now, I have fixed a bunch of issues and made improvements including Hibernate2 support (thanks to Matt Raible) and joined-subclass support.

2. [Hibernate Dev List]

 After a bit of research and thinking, I have settled on an approach to
 query by Criteria that hopefully is flexible enough for 80-90% of use
 cases, but still simple enough to fit in sufficiently few lines of code.
 
 The proposed new API is based loosely upon the Cayenne API. Queries may be
 expressed as follows:
 
 
 List cats = session.createCriteria(Cat.class)
     .add( Expression.like("name", "Izi%" ) )
     .add( Expression.between("weight", minWeight, maxWeight) )
     .add( Expression.eq( "mate", mate ) )
     .addOrder( Order.asc("age") )
     .setMaxResults(20)
     .list();
 
 
 Which is approximately equivalent to:
 
 from Cat cat
 where cat.name like 'Izi%'
 and cat.weight between :minWeight and :maxWeight
 and cat.mate = :mate
 order by cat.age
 
 
 This API is marked "experimental", but I would like to stabilize it fairly
 soon, so early feedback is very welcome. This is all in CVS.

Posted in Java at Mar 09 2003, 09:56:16 AM MST 3 Comments

Struts Training: Week 2

I'm planning on attending today's Struts training and will be reporting here again. I got up at 6, hoping to do the labs and discovered the first step was downloading the latest Basic Portal setup. Since it's 200 MB, I've been dicking around for the last hour and a half, waiting for it to download. Yikes - I thought struts-resume was bad at 10.5 MB! I guess the difference is that it includes JRockit, Mozilla, OpenOffice, Vim, Ant, Eclipse, JMeter, Jikes, PostgreSQL and Resin.

Today's session seems to be covering databases, SQL and database performance. Vic mentions that 90% of performance is in the data model design. If you can fit your database on a laptop, then performance will probably not be an issue. I agree with this. I did the first lab during the first half-hour of the preso. Pretty simple stuff: creating HTML files and accessing them through a browser. This is probably a good lab to get everyone going and stuff installed. Also proves that Resin is running. Of course, it took me two hours to complete this lab, including the download, so I guess it's not that short!

Commons SQL is a new version of Torque (a manual persistence layer). Vic uses RowSets a lot, has one site with 40,000 concurrent Struts users with sub-second response times. He attributes this to rowsets. He says, "To create high-scalable applications, you need to know SQL and use things like RowSet, Ibatis.com, Commons SQL and Scaffolding." I tend to disagree - I think that EJBs (and possibly Hibernate) are your best bet for highly scalable application (i.e. 10,000+ hits per second). If your EJBs are slow, it's probably your code or your appserver. Try EJBs on JBoss and I'm betting you will be pleased. Then again, I've never created a highly-scalable application, and Vic has, so I'm not much of an authority. He, he - he mentions that Castor has lost a lot of mindshare; "Great for development, but not very scalable in production." So true - or at least Roller seems to prove this. From the folks he's talked to, Vic says that TopLink has a horrible reputation.

Hmmmm, interesting. Vic puts all the database connections and CRUD in his ValidatorForms. This is not saying that his bean matches his database tables. I don't know that I'd recommend this, but it certainly might simplify things. However, personally, I'm more comfortable with keeping my POJOs and ActionForms pretty dumb (just getters and setters). He has a DAO that handles CRUD and population of the bean. I wonder where you'd put the business rules in this implementation? In the DAO? If it's in the DAO, what if you have to write a new DAO implementation. For instance, if we used this approach on Roller, we'd have to re-write our business rules for Hibernate and Castor. Ugh.

For testing, he puts a test() method on his beans and uses a Servlet or a plain class with a main() method. Personally, I'd recommend using JUnit and JUnitDoclet (and Ant) to generate and run your unit tests. It's much easier than writing a servlet to test - and can easily separate your tests from your real code. See struts-resume for examples. I'll be releasing AppFuse in the next couple of weeks. This (hopefully) will provide a nice starting point for creating web applications. In reality, if no one uses it, I'll probably be better off (less support). It's been working great for me on my current project and has easily saved us a month of startup time. Right now, appfuse == struts-resume.

Vic mentions using a BaseAction that dispatches to the appropriate method in your subclasses. He says that the only difference between this technique and DispatchAction (or LookupDispatchAction) is you can specify a default method. Here's a tip: use the unspecified method. Here's how to make your edit() method the default:

public ActionForward unspecified(ActionMapping mapping, ActionForm form,
                                 HttpServletRequest request,
                                 HttpServletResponse response)
throws Exception 
{
    return edit(mapping, form, request, response);
}

Vic hints that the next iteration of Basic Portal will be written to use the iBATIS Database Layer and MySQL. Interesting, I thought iBATIS was a company, but nope: it's from the author (Clinton Begin) of JPetstore. On most days, I'd recommend Hibernate here, but I've spent the last 3 days wrestling like mad with it, so I won't. Of course, after leaving work last night, I think I might've figured out the problem. My brain is likely to blame more so than Hibernate.

Ted Husted chimed in at the end and mentioned that he is going to touch on Hibernate next week. Cool!

Posted in Java at Mar 08 2003, 08:13:11 AM MST 4 Comments

Struts-JSF Demo

I've setup another demo - this time it's the struts-example app ported to use JSF and Struts. Nothing ground breaking here that I can tell, and after looking at the code, I don't know what to think of JSF. It seems to make it much harder to code a JSP page.

<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
<%@ taglib prefix="s" uri="http://jakarta.apache.org/struts/tags-faces" %>

<f:use_faces>
<s:html locale="true">
<head>
  <title><
    <s:message key="registration.title.edit"/>
    </title>
  <s:base/>
  <s:stylesheet path="/stylesheet.css"/>
</head>
<body bgcolor="white">

<s:errors/>

<s:form action="/saveRegistration" focus="username"
         onsubmit="return validateRegistrationForm(this);">

  <h:input_hidden id="action" modelReference="registrationForm.action"/>

  <h:panel_grid
           columns="2"
        panelClass="form-background"
       headerClass="form-header"
     columnClasses="form-prompt,form-field">
.
.
.

Ugh, a whole new set of Tag Libraries to learn? Seems like JSF is a lot of bloat, while JSP 2.0 has been made things simpler. One interesting thing is the use of the single-letter (i.e. "h", "s") for the tag libraries. I suggested this a while ago on the struts-dev list, and it looks like it's been implemented. Bravo! I doubt I'm the reason for it, but it's always nice to see your ideas implemented.

I apologize that this site was down most of the day today. It seems that the monitoring/restarting scripts were not running and this should/will be fixed shortly. I need a gig where I can restart this site when it goes down. Anyone know of a way to telnet/ssh via an HTTP Proxy?

Posted in Java at Mar 07 2003, 03:38:29 PM MST 1 Comment

[ANNOUNCE] Struts-JavaServer Faces Integration Library -- Early Access Version Now Available

I'm happy to announce the immediate availability of an integration library
that allows you to use the recently published EA3 release of JavaServer
Faces with a recent Struts build (nightly build 20030216 or later, or 
the upcoming 1.1-rc2 or finalrelease).  Nightly builds of this package are 
available at:

 http://jakarta.apache.org/builds/jakarta-struts/nightly/struts-faces/

The sources for this package are in the  "contrib/struts-faces"
subdirectory of the  "jakarta-struts" CVS repository.

You should take note of the following important points:

* The design goal of this library was to allow Struts application
 developers to migrate the view tier of their applications from the
 existing Struts tags, to pages that use corresponding JavaServer Faces
 component tags, with no changes to the corresponding business logic.
 This goal has been substantially achieved for simple applications
 so far; additional work will be necessary for more advanced apps.
 As a proof of concept, the JavaServer Faces based version of the
 canonical  "struts-example" web application is included in the
 distribution, so that you can see for yourself how little had to be
 changed.

* The integration library has been tested under Tomcat 4.1.18 and
 the Java Web Services Developer Pack (version 1.0_01), although in
 principle it should run on any Servlet 2.3/JSP 1.2 container.
 (It will not run on Servlet 2.2/JSP 1.1 containers).

* There is a known issue when trying to run JavaServer Faces EA3
 under the recently released Java Web Services Developer Pack
 (version 1.1).  Watch the JavaServer Faces web page (at the URL
 listed above) for up-to-date information on workarounds.

* The JavaServer Faces distribution is an EA release, not suitable for
 use in production environments.  In addition, the license terms
 under which it can be downloaded prohibit redistribution.  Therefore,
 you will need to download your own copy of JavaServer Faces EA3 and
 integrate it with the example application before it can be deployed.

* The integration library should also be considered to be of alpha
 quality, not suitable for production use.  There are a set of known
 issues and limitations at the bottom of the README.txt file.  Please
 file bugs against this package in the usual Bugzilla location:

   http://nagoya.apache.org/bugzilla/

* For generic questions about JavaServer Faces (i.e. not related to this
 integration library), your best resource is the JavaServer Faces forum
 (free registration required) at:

   http://forum.java.sun.com/forum.jsp?forum=427

See the README.txt file in the top-level subdirectory for more information
about installing and using this release.

Craig McClanahan

Posted in Java at Mar 06 2003, 09:29:06 PM MST Add a Comment

Struts and JSF - Sample app is on its way!

Craig McClanahan just sent the following message to the struts-dev mailing list after creating a new struts-faces directory (and sub-directories in Struts' CVS tree.

Yep ... it's here ... the promised integration library that lets you use the recently published EA3 release of JavaServer Faces with a recent Struts 1.1 build (see the README.txt for details). Unfortunately, the CVS commit for the actual code was too big for the mailing list -- essentially, it's all the files in the "contrib/struts-faces" subdirectory.

My plan is to publish nightly builds of this code (it's EA quality) but *not* to incorporate it into any formal 1.1 release. More info in an announcement message to come shortly.

Craig

You and I both know the best way to learn JSF (and JSP 2.0) is to start using it on a project. Whether it's your own, an open source project, or a paid project - it's truly the fastest way to enlightenment. I was lucky in my quest to learn Hibernate - I had two concurrent projects (struts-resume and paid) using it.

As far as computers are concerned, I've had a pretty bad day. After writing a long e-mail (about as long as this post), I kicked back in my chair to hit send and kicked the power cord out of the socket! Doh! This actually happens about once a day, but usually I'm coding and testing and I'm saving every 30 seconds. Secondly, I had this post all written and formatted about 10 minutes ago, and Phoenix crashed when I switched tabs to copy/paste something. Damn thing - it's been crashing a lot lately. It might be time to revert back to IE (am now) or Mozilla.

Posted in Java at Mar 06 2003, 08:53:38 PM MST Add a Comment

Ant JMeter Task

By now, you've probably heard of JMeter. It's basically a Swing-based performance testing framework. From the struts-user list today, I found out there's a JMeter Ant Task. Sweet - looks easy to use too. Now if I could just figure out JMeter, or better yet - be tasked with actually implementing it. I've played with it a couple of times, but never long enough to get something I rely on and use.

Anthill, on the other hand, was so easy to install and use that I've set it up at home and I've automated some of my projects' build/deploy processes. I might have to add Roller to the mix. If I were real daring, I could set it up on this server and build/deploy Roller every day or so. Of course, I wouldn't keep this site up to the latest version - I'd setup a 2nd instance of Roller. Any interest in this? Or better yet, do you know anyone that's hosting an Anthill install that we can use?

Posted in Java at Mar 04 2003, 02:07:49 PM MST 1 Comment