Category Archives: Blog Entries

Firefox has overtaken IE on our site

I’m afraid that I don’t know exactly when it happened, but looking at our web-stats (produced by AWStats), the top ten browsers used to access our site are as shown below. It’s not representative of course, but it’s interesting that Firefox is so far above Internet Explorer. Continue reading Firefox has overtaken IE on our site

Plesk, Apache, Tomcat and multiple hosts

In addition to having problems with JNDI not working properly, I’ve also been bashing my head against Plesk–that is supposedly “designed to simplify the management and administration of web sites”.

It’s the interaction between Plesk and Tomcat that’s the particular problem and how both of them negotiate dealing with multiple domains (or rather don’t deal with it). Continue reading Plesk, Apache, Tomcat and multiple hosts

JNDI problems with Tomcat 5.5.15

I’ve recently been having difficulty getting JNDI lookup for MySQL connection pools working on our public server.

This proved very difficult to track down as all the stuff that I could find on the web said that I had to have:

  • commons-dbcp-1.2.1.jar
  • commons-pool-1.2.jar
  • mysql-connector-java-3.1.6-bin.jar

(or the latest appropriate versions)

Unfortunately this didn’t work and my little test JSP (using the JSTL sql tags) just gave me the error: DataSource invalid:
“java.sql.SQLException: No suitable driver.

However, next I tried connecting to MySQL directly using Class.forName(""com.mysql.jdbc.Driver") and that worked. So the problem wasn’t in loading the driver. Continue reading JNDI problems with Tomcat 5.5.15

Outputting stack traces in a JSP using JSTL

If you’re writing a JSP using the JSTL tag <c:catch var=”myError”> … </c:catch> then I’m sure that you know that the next thing to do is to check after the closing catch tag to see if myError is empty. If not you can output some useful error message having successfully caught any exception. However, sometimes it’s useful to actually output the stack trace (when debugging a site for example). It turns out not to be difficult to do this. Simply copy in the following:

<c:if test="${not empty myError}">
<p class="error">An error occured: <c:out value="${myError}"/></p>
<c:forEach var="stackTraceElem" items="${myError.stackTrace}">
<c:out value="${stackTraceElem}"/><br/>

HTML Testing, Ruby and Selenium

One of the problems with using HTML as the user interface is testing it (in fact testing user interfaces has always been a bit of a problem) so I’m always on the look out for good UI testing tools.

For a while I’ve known about and used Watir which scripts Internet Explorer (and now Firefox with FireWatir though it’s a bit more tricky to set up). Watir allows you to write simple but powerful scripts in Ruby that will instruct IE to load up a page, fill in a form, click a button or whatever and then you can make assertions about what should have happened. It’s not difficult to use and even if you don’t know Ruby, if you know other languages, you can soon pick it up.

Today however I came across Selenium (also on the same OpenQA site). This is neat for two reasons: (1) it’s all written in JavaScript so the same script runs in both IE and Firefox, on the PC or Mac; and (2) it has an IDE (a Firefox extension in fact) which lets you record the tests rather than having to write them yourself (you can then save them away and create test suites; you can also load up tests and single step them, etc.). (There is a Watir recorder on the OpenQA site but it’s only version 0.1 so far. There’s also WET which I haven’t tested, but is a Windows application written in Ruby which wraps around Watir.)

The thing I’m currently looking for though is a test environment where I don’t have to install a large infrastructure and which works easily on both PCs and Macs, supporting both IE and Firefox. Selenium seems to give me exactly that. In fact the project’s customer could probably install it on their PC and be able to run the tests (or even record new tests) which would be great.

Please let me know if you know of other tools that would fit the bill or what your experience is with these tools.

Confirming a URL in Javascript

This is a little tip that I discovered a while ago but which I’m always forgetting, so I thought I’d post it here where I woudn’t lose it! Sometimes you’ll have a link on a web page which actually does something to a database, deletes the current thing for example. In those circumstances you want to have some sort of “Are you sure?” confirmation.

Javascript has a confirm dialog that you can use, but because you can use the return value of a method to determine event bubbling, you can use this really neatly to give optional links as follows:

Click here to go to home page

And of course you can try it yourself: Click here to go to home page.

If you click OK, then the confirm returns true and the link is followed. If you click Cancel, then confirm returns false and the event isn’t bubbled up to the href handler and so the link isn’t followed and you stay on the same page.

Javascript debugging, Firefox and Drag and Drop

In one of my current projects I need to have a table of data that the user can reorder. A quick search of the internet doesn’t turn up any javascript howtos or frameworks that allow dragging and dropping of table rows, so I had to role my own. I’ve written an article about how to do it, here. Continue reading Javascript debugging, Firefox and Drag and Drop

Using Parallels to run Windows on a MacBook

I haven’t added anything to the blog for a few months as I’ve been busy on a number of fronts. First I’ve swapped over to using a MacBook for day-to-day development. It took me a while to get used to, especially as the keyboard layout in the UK is different from the PC–and it took me a while to discover that that # is produced using ALT-3 and isn’t even shown on the keyboard. But I love it! It works really well.

I use IntelliJ and Eclipse for development with Firefox for Java, PHP and Web development so it’s not much different. MS Office 2004 for the Mac is very different from Office 2003 for the PC, but all works as expected (though there’s no plug-in for the docx format yet). It’s very nice having Unix under the hood too.

However, there are a couple of things I still need a PC for, and the most important of those is running Internet Explorer so that I can test web pages. I have other PCs lying around, so I could use those, but the solution I’ve gone for is to use Parallels ( This allows you to run a Windows virtual machine (and Unix if you like) at the same time as MacOS. So I have MacOS for development and then Windows in a window. Windows has access to the DVD drive and internet and behaves just like the real thing–well it is the real thing (you do need a Windows operating system license to install it). So I can run Internet Explorer and any other PC-only tools on my Mac whenever I need them.

UTF-8 with Hibernate 3.0 and MySQL

Hi again, I’m now tackling something I’ve been meaning to do for ages (and probably should have done before I started the project) and that is to use Hibernate rather than rolling my own SQL.

I’m reading the book “Hibernate in Action” by Christian Bauer and Gavin King and have been trying it out. The book relates to Hibernate 2.0 and 2.1 so doesn’t include annotations which is a bit of a shame, but it’s still a good start.

Unfortunately as readers of this blog will know, I’m trying to put UTF-8 strings into the database so you can imagine my disappointment when I saw the familiar question marks appearing where there should be interesting new characters.

The fix turned out to be not so difficult to find however, thanks to Philip Whirlycott’s blog posting More UTF-8 head-thumping with Hibernate 3 (obviously I’m not the only one struggling with these issues).

With Hibernate 3 (maybe not with 2.1, I’m not sure), you need to add some extra connection parameters:


If you put this in your hibernate.cfg.xml file for the JDBC URL it works and you can save the UTF-8 correctly.

Replacing your hard disk

A friend of mine had that dreaded moment when his main PC wouldn’t boot. Backups? Yes, well I was going to get round to it….

I suggested that he should insert the Windows XP CD and see if he could boot from that. He was lucky and he was able to do that and get Windows XP to repair itself enough to run up and view the data on the hard disk, in fact for a while it did seem to work.

But this obviously wasn’t going to last for long, the primary hard disk was definitely on the way out. So he needed to replace the hard disk. But that’s always a pain because you have to re-install everything from scratch and that can take days.

Instead, he bought a new hard disk, borrowed my hard disk external USB caddy (which you can find on the net for about GBP20) and downloaded a bit of software called Acronis True Image 9.0.

With this he was able to make an image of his old hard disk. He then replaced the old hard disk with the new one and amazingly enough it booted with pretty much everthing there.

It wasn’t quite transparent, here’s what he told me afterwards:

Some but not all of the registry details are lost when you copy the disk. There does not seem to be any particular logic to the ones that are lost. However, as I think I told you – Photoshop needed to be “re-registered”. I had to boot Windows from the installation disk – (so far only once) but didn’t actually have to re-register it with Microsoft. My Palm Pilot needed to be re-registered. Similarly, almost all the bits of hardware that run off USB ports need to reload the drivers.

Nevertheless, a lot quicker than starting from scratch.

On the other hand, the main advantage from starting from scratch is that there ends up being loads of software you never do re-install, so it is a good way of weeding out stuff :-)