Month: July 2005

  • Java Document to String

    by

    in

    This is a very simple utility function to produce an indented XML document as a String given a Document. It throws a TransformerException if anything drastic goes wrong. [java] import java.io.*; import org.w3c.dom.Document; import javax.xml.transform.*; import javax.xml.transform.dom.DOMSource; … public static String documentToString( Document document ) throws TransformerException { TransformerFactory tFactory = TransformerFactory.newInstance(); Transformer transformer =…

  • Velocity if statement is type sensitive…

    Problem I discovered that comparisons in Velocity if statements are type-sensitive the hard way. For example, I am trying to display the ‘selected’ option in a html <SELECT> object. The list of possible values is $list, each is a simple ‘NameValuePair’ value object { String name, String value }. The object I am editing in…

  • Time Synchronisation With Windows 2000 or XP

    If you’re running Windows 2000 or XP at home, it’s very unlikley that you have a ‘Primary Domain Controller’ to give you the time of day. 😉 Windows 2000 & XP has a built in “Windows Time” service that is also compatible with public SNTP Time Servers, all you need to do is configure it.…

  • Fedora Core 4 and SELinux paranoia

    by

    in

    The default configuration of Fedora Core 4 with SELinux enabled causes problems when you want to use the UserDir feature in Apache Httpd. Problem: SELinux is stopping the httpd processes from accessing your home directory. [code] Forbidden You don’t have permission to access /~foo/ on this server. Additionally, a 403 Forbidden error was encountered while…

  • Velocity Templates and Newlines

    If you’re reading this article you’ve probably encounted the same problem as I have. I was trying to put a newline ‘\n’ character in the value of a variable in a Velocity template. Attempt 1: I assumed \n would work… [code] #if ( !$foo ) #set ( $foo = “There was no foo set in…

  • Java Object Digester

    by

    in

    I was working on a web-based application recently and wanted a lazy way to get data from a simple ‘value object’ out to the front end without having any hard-coded field names; I came up with this. Basically, this method will take any Object, iterate through its methods looking for any of the format “get<something>”…

  • Unicode? Character Sets? UTF-what?

    I was inspired to add this note after recent frustrations about the complete ignorance of character sets in both Commercial & Open software… I seriously recommend everyone reads the following, less ISO-blahblahblah and more UTF-8, no excuses! The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!) http://www.joelonsoftware.com/articles/Unicode.html