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.

Commons Lang: StringUtils

My new favorite method is the equals method on Commons Lang's StringUtils class. It takes the check for null out of your logic and can help you create cleaner code. Before using it you might have to write something like this:

if (request.getParameter("checkbox") != null 
    && (request.getParameter("checkbox").equals("true"))) {

With StringUtils.equals(String, String), you get a little less coding:

if (StringUtils.equals(request.getParameter("checkbox"), "true")) {

If you're using Struts or some other library that already depends on commons-lang, why wouldn't you use it? Possibly performance reasons, but I doubt it causes much of a hit.

Posted in Java at Jan 22 2003, 06:05:51 AM MST 4 Comments

Using XDoclet to generate your validation.xml?

Are you using XDoclet to generate the validation.xml file for Struts' Validator Framework? If you're using Struts and you're not using the Validator - you should be IMO. It makes both client-side and server-side validation soooo simple. Using XDoclet to generate the key file (validation.xml) makes implementation a piece of cake. We have Erik to thank for this wonderful addition to XDoclet. Much appreciated sir!

I'm guessing that not many people are using this feature b/c it works kinda funky right now. It disregards the order of your properties in your ValidatorForm and generates entries in alphabetical order. This is great except the client-side (JavaScript) piece of the Validator uses the order to determine which fields to validate first. This has caused a slight headache for me on my project, so I fixed it. Checkout XDoclet's JIRA for the bug and the patch. Hopefully it'll get committed soon, but in the meantime, I'll continue using my patched Apache module that allows me to generate ActionForms from POJOs and orders my validation.xml correctly.

Posted in Java at Jan 21 2003, 10:12:23 PM MST 6 Comments

Java Development with Ant Quiz

Sun has a Ant Quiz. Test your Ant knowledge! I missed 2 - #5 and #9. Number 9 asks "XDoclet is?" You'd think I've worked with it enough by now to know what the heck it is - but apparently not. ;-)

Posted in Java at Jan 21 2003, 08:21:26 PM MST Add a Comment

Where do you locate your daemons?

On my current project, we're developing an application that has two components. One is a webapp that lives in Tomcat and the other is a standalone jar that runs as a daemon. The daemon checks an e-mail Inbox every few minutes and if there's new mail, it processes the Excel attachments and enters this information in a database. My question is: where on the filesystem should we put this daemon? We're running on Red Hat 8 - maybe /usr/local/mail-daemon or something? BTW, we were running on BSD, but it's Java wasn't up to snuff (didn't support 1.4) - so we're running Linux instead. I dig the Linux/Java combo - it just works!

Posted in Java at Jan 21 2003, 07:47:35 AM MST 3 Comments

Clustering Tomcat

If my load balancing with Tomcat and Apache article is not what you're looking for - maybe you want to setup Tomcat clustering. If so, check out the tomcat-javagroups project at SourceForge.

I saw a couple of e-mails yesterday on the tomcat-user mailing list asking about migrating a Resin-based application to Tomcat. Turns out that Resin let's you do a bunch of non-standard stuff and doesn't validate DTDs, so migrating can be a headache. So, if you're smart, you'll follow standards and chances are your webapp will work on all appservers. Kinda like XHTML - follow standards and the containers/browsers will follow.

Posted in Java at Jan 21 2003, 05:29:56 AM MST 2 Comments

Flash and J2EE and Apache 2.0.44

Erik hooks us up with some small but cool headlines on this early Tuesday morning.

javaEnhance your J2EE presentation layer. Flash Remoting introduces an alternative. netApache 2.0.44. A security and bug fix release.

While you're here (if you are actually viewing this post through a browser), check out the cool help tip on the picture of red rocks. Click and read. To see how I did this, check webfx.nu.

Posted in Java at Jan 21 2003, 05:05:11 AM MST Add a Comment

Hibernate Help Needed

I'll try the approach that Lance used to solve my Hibernate problem. First, I'll explain the problem. In two days, if I haven't solved it - I'll bash on Hibernate and say it s***s (can't do it yet - right ;-), and then I'll claim it rocks once I get my problem solved. Hmmm, it took Lance 4 days - I have 3 before my deadline (Thursday). Luckily, I know of workarounds already (I just want to do things the recommended way) - therefore, I should never have to bash on Hibernate.

My problem is basically that I have a Parent object and it has a one-to-many relationship to a Child object. This is usually a very simple thing to configure in a Parent.hbm.xml file. To make things complicated, my Child object has a composite-id which is another class. I can retrieve information just fine, but when I try to save the Parent, Hibernate tries to insert a new Child. Here's the message I sent to the hibernate-devel mailing list:

** all classes extend from BaseObject with has equals(), 
   hashCode() and toString() methods.

Parent.java
---
private Long id;
private List children;
+appropriate getters/setters

Parent.hbm.xml
---
<bag role="children" table="CHILDREN" cascade="all">
    <key column="parent_id" length="22"/>
    <one-to-many class="eg.Child"/>
</bag>

Child.java
---
private ChildId id;
+appropriate getter/setter

ChildId.java
---
private Long parentId;
private Long recordNum;
+ appropriate getter/setters

Child.hbm.xml
---
<composite-id name="id"
    class="eg.ChildId"
    unsaved-value="none">
    <key-property column="parent_id" length="22" 
        name="parentId" type="long"/>
    <key-property column="record_num" length="22" 
        name="recordNum" type="long"/>
</composite-id>

I am able to retrieve children just fine, but when I try to save 
the parent, hibernate tries to do an insert and I get a unique 
constraint violation.

I'm calling the following method to save everything:

public Parent saveParent(Parent p) throws DAOException {
    storeObject(p);
    return (Parent) retrieveObject(eg.Parent.class, p.getId());
}

I got the storeObject method from one of the examples floating 
around, so it could definitely be my problem:

protected void storeObject(Object obj) throws DAOException {
    Session ses = null;

    try {
        ses = HibernateSession.currentSession();
        ses.saveOrUpdate(obj);
        ses.flush();
        ses.connection().commit();
    } catch (Exception e) {
        try {
            ses.connection().rollback();
        } catch (Exception ex) {
            e.printStackTrace();
        }

        ;
        throw new DAOException(e);
    } finally {
        try {
            HibernateSession.closeSession();
        } catch (Exception ex) {
            ex.printStackTrace();
        }

        ;
    }
}

As always, any help is greatly appreciated.

Posted in Java at Jan 20 2003, 07:17:41 PM MST 8 Comments

[ANNOUNCE] Manywhere Moblogger

moblogger logo Russ has released moblogger, which maybe exactly what I am looking for. It seems that I can use it to e-mail posts to this site.

This application runs as a background process that monitors a POP3 email account for new email, then downloads it, detaches any files such as pictures, sound or video, uses the Blogger API to post the text in the email to your blog and uses FTP to post the files to your server. Send the email from a phone and you immediately start "moblogging".
...
When you send email, put your password in the subject line!! Since the blogger API doesn't support titles, this is a good place to make sure that some random person or spammer doesn't start posting to your blog by sending an email.

That's a cool way to get around the authentication problem. I think the latest blogger API does support titles, but I definitely could be mistaken. I suppose if I were an ambitious fellow, I could do some research on the bloggerDev mailing list - but I'll pass. Unfortunately, I dig titles and while I may use Russ's tool, I'll probably still have to edit/create titles. One thing I'd like to do with Roller's Editor UI is to make is WAP compatible - since it's XHTML, I could be able to create a set of JSPs with JSTL and XSL and blowee, there's your mobUI. I don't know that I'd actually ever use it though. I rarely even make phone calls on my T68i, let alone browse the web.

Posted in Java at Jan 20 2003, 05:07:49 AM MST Add a Comment

xPetstore v2.2 Released!

I haven't looked at it much or used it at all, but it sounds good.

xPetStore is a WODRA (Write Once, Deploy and Run Anywhere) implementation of Sun PetStore application based on the following opensource tools/framework:
- XDoclet
- Struts
- SiteMesh

If you're writing web applications (and you're using Struts or Webwork) and you're NOT using XDoclet (or one if it's derivatives - i.e. Middlegen), you're wasting your time (IMHO). Of course, I also believe that if you're not using Ant to build your java-based project, you're really wasting your time.

Hmmm, while over at the WebWork site, I stumbled upon this Eclipse + Resin + WebWork + Hibernate tutorial. I don't know if it's such a good idea to call your persistence layer directly from your servlets is it? Shouldn't that be in a Business Delegate - or am I losing focus of KISS and trying to follow too many patterns? Patterns give me more opportunities for Unit Testing. The only way to test this servlet would be something like Cactus, right? As always, to each his own... ;-)

Posted in Java at Jan 19 2003, 10:24:25 PM MST 1 Comment

A Hitchhiker's Guide to Hibernate

Glen Smith has published A Hitchhiker's Guide to Hibernate. This looks like a nice simple intro to Hibernate. This tutorial (IMO) is a great stepping stone to demonstrate how to use XDoclet to do the same thing (it creates the mapping file for you), and also do demonstrate using a ServletFilter and ThreadLocal for obtaining the session. There have been recent postings regarding these techniques to the hibernate-devel mailing list (in case you're interested).

I also found Tom Sedge's explanation of associations on the Hibernate site - looks like I have some reading to do!

Posted in Java at Jan 19 2003, 11:06:21 AM MST Add a Comment