Jakarta Commons Cookbook


As a Java developer, you're always looking for tools to help in your web and application development. Maybe you've heard of the Jakarta Commons open source Java tools. The Jakarta Commons is an open source Jakarta subproject where developers create and maintain a collection of twenty-plus independent Java components and utilities that serve useful purposes. Jakarta Commons packages include utilities for web, XML, networking, building and testing applications, and some that help other packages work better ...

See more details below
BN.com price
(Save 41%)$44.95 List Price
Other sellers (Paperback)
  • All (22) from $1.99   
  • New (5) from $18.88   
  • Used (17) from $1.99   
Sending request ...


As a Java developer, you're always looking for tools to help in your web and application development. Maybe you've heard of the Jakarta Commons open source Java tools. The Jakarta Commons is an open source Jakarta subproject where developers create and maintain a collection of twenty-plus independent Java components and utilities that serve useful purposes. Jakarta Commons packages include utilities for web, XML, networking, building and testing applications, and some that help other packages work better together. Jakarta Commons packages are designed to be reusable. Each one is a time saver by itself, and when used in combination the results can be very powerful.But in searching for information on the Jakarta Commons tools, you find it hard to locate documentation relevant to your needs. You don't have lots of time to spend searching for information on a specific Jakarta Commons tool to determine what it does and how to incorporate it in your code. If you are looking for a single source for clear information and samples on how to use the Jakarta Commons tools, then the Jakarta Commons Cookbook is for you.The Jakarta Commons Cookbook summarizes each of the available Jakarta Commons packages and contains practical and efficient recipes for making the most out of the Jakarta Commons open source Java tools. You don't have to be an expert, since the book explains how and why to use a utility, pitfalls to avoid, and where to look for additional information on Jakarta Commons utilities. It introduces design possibilities and explores combining Jakarta Commons utilities in novel assemblies to create complex applications. The book offers detailed code samples and insider tips—making it a valuable resource whether you are an expert Java developer or a novice. If you want to quickly learn how to use Jakarta Commons timing-saving utilities or have an invaluable resource for Jakarta Commons questions and techniques, then the Jakarta Commons Cookbook is for you.

Read More Show Less

Product Details

  • ISBN-13: 9780596007065
  • Publisher: O'Reilly Media, Incorporated
  • Publication date: 11/28/2004
  • Edition number: 1
  • Pages: 400
  • Product dimensions: 6.78 (w) x 9.40 (h) x 1.07 (d)

Meet the Author

Tim O'Brien is an active committer in the Jakarta Commons, a sub-project of the Apache Software Foundation's Jakarta project. As a consultant, Tim tries to encourage the adoption of open-source software, and nudge organizations to view community participation as an essential strategy. In addition to his professional responsibilities, he is a Bass/Baritone who sings frequently in the Chicagoland area. Tim discovered programming on a Basic Four, TRS-80, and Commodore 64 in his hometown of Wellesley, Massachusetts; subsequently, studying Computer Engineering at the Universityof Virginia

Read More Show Less

Table of Contents

What’s Inside;
Conventions Used in This Book;
What You’ll Need;
The Jakarta Commons Community;
The Apache Software License;
Using Code Examples;
We’d Like to Hear from You;
Chapter 1: Supplements to the Java 2 Platform;
1.1 Introduction;
1.2 Obtaining Commons Lang;
1.3 Joining the Commons-User Mailing List;
1.4 Getting the Commons Lang Source Code;
1.5 Automating the Generation of toString( ) Content;
1.6 Customizing Generated toString( ) Content;
1.7 Automating hashCode( ) and equals( );
1.8 Automating compareTo( );
1.9 Printing an Array;
1.10 Cloning and Reversing Arrays;
1.11 Transforming Between Object Arraysand Primitive Arrays;
1.12 Finding Items in an Array;
1.13 Creating a Map from a Multidimensional Array;
1.14 Formatting Dates;
1.15 Rounding Date Objects;
1.16 Truncating Date Objects;
1.17 Creating an Enum;
1.18 Generating Unique Numeric Identifiers;
1.19 Validation of Method Parameters;
1.20 Measuring Time;
Chapter 2: Manipulating Text;
2.1 Introduction;
2.2 Setting Up StringUtils and WordUtils;
2.3 Checking for an Empty String;
2.4 Abbreviating Strings;
2.5 Splitting a String;
2.6 Finding Nested Strings;
2.7 Stripping and Trimming a String;
2.8 Chomping a String;
2.9 Creating an Emphasized Header;
2.10 Reversing a String;
2.11 Wrapping Words;
2.12 Testing the Contents of a String;
2.13 Measuring the Frequency of a String;
2.14 Parsing Formatted Strings;
2.15 Calculating String Difference;
2.16 Using Commons Codec;
2.17 Getting the Commons Codec Source Code;
2.18 Calculating Soundex;
Chapter 3: JavaBeans;
3.1 Introduction;
3.2 Representing Beans Graphically;
3.3 Obtaining Commons BeanUtils;
3.4 Getting the Commons BeanUtils Source Code;
3.5 Accessing Simple Bean Properties;
3.6 Accessing Nested Bean Properties;
3.7 Accessing Indexed Bean Properties;
3.8 Accessing Mapped Bean Properties;
3.9 Accessing a Simple, Nested, Indexed, and Mapped Bean Property;
3.10 Determining the Type of a Bean Property;
3.11 Comparing Beans;
3.12 Copying Bean Properties;
3.13 Cloning a Bean;
3.14 Setting a Bean Property;
3.15 Testing Property Access;
3.16 Validating Beans with Predicates;
3.17 Creating a Map of Bean Properties;
3.18 Wrapping a Bean with a Map;
3.19 Creating a Dynamic Bean;
3.20 Getting and Setting Properties as Strings;
Chapter 4: Functors;
4.1 Introduction;
4.2 Obtaining Commons Collections;
4.3 Getting the Commons Collections Source Code;
4.4 Reversing a Comparator;
4.5 Chaining Comparators;
4.6 Comparing Nulls;
4.7 Fixed-Order Comparison;
4.8 Using Simple Predicates;
4.9 Writing a Custom Predicate;
4.10 Creating Composite Predicates;
4.11 Transforming Objects;
4.12 Creating a Chain of Transformations;
4.13 Applying Conditional Transformations;
4.14 Writing a Closure;
4.15 Chaining Closures;
4.16 Modeling Conditional Statements with Closures;
4.17 Modeling Loops with Closures;
Chapter 5: Collections;
5.1 Introduction;
5.2 Obtaining Commons Collections;
5.3 Using a Looping Iterator;
5.4 Iterating Over an ArrayList;
5.5 Filtering a Collection with a Predicate;
5.6 Iterating Through Distinct Elements;
5.7 Using a Bag;
5.8 Using a Buffer;
5.9 Creating a Priority Queue;
5.10 Using a Blocking Buffer;
5.11 Storing Multiple Values in a Map;
5.12 Retrieving a Key by a Value;
5.13 Using a Case-Insensitive Map;
5.14 Creating Typed Collections and Maps;
5.15 Constraining Map Values;
5.16 Constraining List Contents;
5.17 Transforming Collections;
5.18 Creating a Least Recently Used Cache;
5.19 Using a Lazy Map;
5.20 Counting Objects in a Collection;
5.21 Performing Set Operations;
5.22 Retrieving Map Values Without Casting;
Chapter 6: XML;
6.1 Introduction;
6.2 Obtaining Jakarta Commons Digester;
6.3 Turning XML Documents into Objects;
6.4 Namespace-Aware Parsing;
6.5 Creating a Simple XML Command Language;
6.6 Variable Substitution and XML Parsing;
6.7 Obtaining Jakarta Commons Betwixt;
6.8 Turning Beans into XML Documents;
6.9 Customizing XML Generated from an Object;
6.10 Turning XML Documents into Beans;
Chapter 7: Application Infrastructure;
7.1 Introduction;
7.2 Obtaining Commons CLI;
7.3 Parsing a Simple Command Line;
7.4 Parsing a Complex Command Line;
7.5 Printing Usage Information;
7.6 Obtaining Commons Configuration;
7.7 Configuring Applications with Properties Files;
7.8 Configuring Applications with XML;
7.9 Using Composite Configuration;
7.10 Obtaining Commons Logging;
7.11 Using an Abstract Logging Interface;
7.12 Specifying a Logging Implementation;
7.13 Obtaining Apache Log4J;
7.14 Configuring Log4J with a Properties File;
7.15 Configuring Log4J with XML;
Chapter 8: Math;
8.1 Introduction;
8.2 Using Fractions;
8.3 Finding the Maximum and Minimum in an Array;
8.4 Using Number Ranges;
8.5 Generating Random Variables;
8.6 Obtaining Commons Math;
8.7 Calculating Simple Univariate Statistics;
8.8 Solving a System of Linear Equations;
8.9 Arithmetic with Complex Numbers;
8.10 Establishing Relationships Between Variables;
8.11 Estimating the Amount of Time Left in a Process;
Chapter 9: Templating;
9.1 Introduction;
9.2 Obtaining Commons JEXL;
9.3 Using an Expression Language;
9.4 Invoking Methods in an Expression;
9.5 Externalizing Logic with an Expression Language;
9.6 Obtaining Jakarta Velocity;
9.7 Using a Simple Templating Language;
9.8 Writing Templates with Conditionals and Loops;
9.9 Using Macros in a Templating Engine;
9.10 Invoking Methods in a Template;
9.11 Obtaining FreeMarker;
9.12 Using a Complex Scripting Engine;
9.13 Accessing XML Documents from a Templating Engine;
9.14 Using Velocity in a Web Application;
9.15 Using FreeMarker in a Web Application;
9.16 Writing Templates in Eclipse;
Chapter 10: I/O and Networking;
10.1 Introduction;
10.2 Obtaining Commons IO;
10.3 Copying Streams, byte[ ], Readers, and Writers;
10.4 Closing Streams, Readers, and Writers;
10.5 Printing a Human-Readable File Size;
10.6 Copying Files, Strings, and URLs;
10.7 Deleting Directories Recursively;
10.8 Obtaining the Size of a Directory;
10.9 Touching a File;
10.10 Filtering Files;
10.11 Measuring Stream Traffic;
10.12 Splitting an OutputStream;
10.13 Obtaining Jakarta ORO;
10.14 Using Globs and Perl5 Regular Expressions to List Files;
10.15 Obtaining Commons Net;
10.16 Writing an FTP Client;
10.17 Sending Mail with SMTP;
10.18 Checking a POP3 Mailbox;
Chapter 11: HTTP and WebDAV;
11.1 Introduction;
11.2 Obtaining Jakarta HttpClient;
11.3 Getting Jakarta HttpClient Source Code;
11.4 Performing an HTTP GET;
11.5 Sending Parameters in a Query String;
11.6 Retrieving Content with a Conditional GET;
11.7 Debugging HTTP Communications;
11.8 Making an HTTP POST Request;
11.9 Sending POST Data from a File;
11.10 Uploading Files with a Multipart POST;
11.11 Basic Authentication;
11.12 NTLM Authentication;
11.13 Working with Cookies;
11.14 Handling Redirects;
11.15 SSL;
11.16 Accepting a Self-Signed Certificate;
11.17 Obtaining Jakarta Slide;
11.18 Connecting to WebDAV Resources;
11.19 Modifying a WebDAV Resource;
Chapter 12: Searching and Filtering;
12.1 Introduction;
12.2 Obtaining Commons JXPath;
12.3 Querying an Object Graph with XPath;
12.4 Search a Collection of Simple Objects;
12.5 Applying XPath Queries to Complex Object Graphs;
12.6 Obtaining Jakarta Lucene;
12.7 Creating an Index of XML Documents;
12.8 Searching for a Specific Term in a Document Index;
12.9 Finding the Frequency of Terms in an Index;

Read More Show Less

Customer Reviews

Be the first to write a review
( 0 )
Rating Distribution

5 Star


4 Star


3 Star


2 Star


1 Star


Your Rating:

Your Name: Create a Pen Name or

Barnes & Noble.com Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & Noble.com that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & Noble.com does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at BN.com or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation


  • - By submitting a review, you grant to Barnes & Noble.com and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Noble.com Terms of Use.
  • - Barnes & Noble.com reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & Noble.com also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on BN.com. It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously
Sort by: Showing 1 Customer Reviews
  • Anonymous

    Posted December 3, 2004

    for numerical methods

    One of the beauties about Java, compared to earlier languages like C or Pascal, is the huge set of library classes that comes with the default distribution. An immense amount of code, all for free. Any experienced Java programmer knows this. But what if you could also get another set of free classes that extends the functionality even more? And has been well tested? O'Brien educates us about this - the Jakarta Commons. A nifty amount of heavy code. It can be highly worth your while to peruse this for useful classes. Here is a brief excerpt of what is offered. Consider the default maths classes that come with Java. Important. But still very primitive compared to the decades of effort put into various mathematical libraries in other languages like Fortran. Of course, many of those tend to be proprietary. Now, in Commons, we have Maths classes. These can solve a linear system of equations. In other words, matrix arithmetic is implemented. Opens up entire regions of electrical circuit modelling and control systems theory, for example. For statistics, simple regressions between two variables is now computed. And complex numbers can be explicitly handled with the ComplexMath class. It can be appreciated that the new Commons maths classes fill longstanding gaps in the default maths ability of Java, which has been weak in numerical methods and high performance computing. It greatly strengthens the credibility of developing applications in those fields with Java.

    Was this review helpful? Yes  No   Report this review
Sort by: Showing 1 Customer Reviews

If you find inappropriate content, please report it to Barnes & Noble
Why is this product inappropriate?
Comments (optional)