Quantcast

Ben McCann

Co-founder at Connectifier.
ex-Googler. CMU alum.

AngelList Twitter LinkedIn Google+

Java

Case Study: Usable and Unusable APIs

07/25/2009

It was the best of times, it was the worst of times… It was the age of wisdom, it was the season of light.  A great library called dom4j was written with its users in mind.  It included a quick start guide and a cookbook for people that actually wanted to get things done.  Converting Read More

Sample log4j.properties file

07/18/2009

I always find the hardest part of getting started with log4j is creating a log4j.properties file. For that reason, I’ve posted an example below. This file configures log4j to log any messages of level info or higher to the console except for classes under the com.dappit.Dapper.parser or org.w3c.tidy packages. #—————————————————————————— # # The following properties Read More

Printing a Stack Trace anywhere in Java

07/03/2009

You don’t need to catch an Exception in order to print a stack trace in Java.  Sometimes they can be helpful for debugging and logging purposes.  Here’s an example of how to print a stack trace at any moment: new Exception().printStackTrace(); If you want more control over the output, you can build some code off Read More

Maven on Eclipse Tutorial

04/12/2009

Install Java and Maven First off, make sure you have a Java JDK installed and that your JAVA_HOME environment variable points to it. You can check by typing “echo %JAVA_HOME%” in Windows or “echo $JAVA_HOME” in Linux. You’ll next want to download and install Maven by following the directions on their website.  Once Maven is Read More

Using the GWT ClickListener on an Element

11/24/2008

GWT uses what it calls a ClickListener instead of the standard HTML onclick attribute.  The normal way to use a GWT CLickListener would be as follows: focusWidget.addClickListener(new ClickListener() { public void onClick(Widget sender) { // do something here } }); Unfortunately, this seems not to work on an HTML Element.  Luckily, you can use JSNI Read More

Struts 2 Tutorial – Validation and Error Handling

09/20/2008

Validation is an important part of any web framework because it is one of the most painfully repetitive things to have to continually recreate.  In Struts 2, validation is handled by creating an Action-validation.xml file.  So, if we have an AddUser Action then we would create an AddUser-validation.xml file: <!DOCTYPE validators PUBLIC “-//OpenSymphony Group//XWork Validator Read More

Struts 2 Tutorial – Struts Configuration

09/20/2008

The struts.xml file defines the relationship between actions and .jsp views, the inclusion of interceptors, and possible result types.  It’s essential that you be able to handle at least basic configuration changes, so we’ll demonstrate the most important and frequently used below. Packages: Extension, Namespaces, and More For more complex applications, you will likely want Read More

Struts 2 Tutorial – Interceptors

09/19/2008

Interceptors are my favorite aspect of Struts 2. They inspect and/or act on a user’s request. There are three main uses cases that I’ll discuss here: intercepting before the action, between the action and view, and after the view. At the end, I’ll show you how to add your brand spankin’ new interceptor to your Read More

Struts 2 Tutorial – Creating Views

09/09/2008

One of the first things you’ll want to do after getting started with Struts 2 is create more complex user interfaces. We call the UI a view because Struts2 makes use of the Model-View-Controller (MVC) design pattern.  For this example, let’s assume we have an action that returns a list of all the employees at Read More

Newer Posts
Older Posts