Searching for files in an Ant script

Steve Neal Development, Tool support Leave a Comment

This is a simple technique for determining whether or not files matching a given pattern exist within your project. Unlike the available task, this does not require that you need to know the exact name of the file when creating the build file. It is therefore very useful for checking existence of generated/downloaded artefacts. I’ll demonstrate the technique with an …

Adding a thread timeout to methods in Java

Steve Neal Development, Java Programming 1 Comment

When calling a method that could potentially take longer that you’d like to complete, it is possible to write code that will back out after a given time period. This can happen in numerous circumstances where you’d like an application to maintain a degree of liveness. I’ve used it recently in an application that needed to run a number of …

Count the processors on a Linux server

Steve Neal Linux Leave a Comment

If you need to see how many processors there are available on a Linu/Unix server, use the following command from your shell: cat /proc/cpuinfo | grep processor each of the processors will be listed in the output. For example, on a server I use the output looks like this: processor : 0 processor : 1 processor : 2 processor : …

What info can you get from an HttpServletRequest?

Steve Neal Development, Java Programming Leave a Comment

There are many methods on an HttpServletRequest, and if you’re anything like me, you’ll forget exactly what each of them returns. Rather than a long winded investigation into them all, here’s a sample URL: https://localhost:8443/test/welcome?a=1&b=2 The ‘/test’ in the URL will map to a servlet called test. The servlet will dispatch the request to a JSP for rendering that has …

Implementing Flash Scope in Java Web Applications

Steve Neal Development, Java Programming 6 Comments

While working recently on a Spring MVC project I found myself wishing it supported flash scope. I hunted around for a simple solution but couldn’t find anything that didn’t rely on having to import large framework libraries. After a little thought I came up with the following simple and lightweight solution that has worked really well for me. I’ve included …

Using recursion to program in JSP

Steve Neal Development Leave a Comment

I needed to render a tree structure in a JSP and wanted to use a recursive solution like this: After a while of not getting very far with this and trying to figure out why I was getting stack overflow errors, I figured out that the jsp:param tag was not passing the state across as I’d expected in the recursive …

Address in Use Error using Tomcat on Windows XP

Steve Neal Development 2 Comments

Occasionally you might get an error like this when launching Tomcat: java.net.BindException: Address already in use: JVM_Bind <null>:8080 This can be caused if you already have Tomcat running as it will hold onto a network port for handling HTTP requests. In the above example the port shown is 8080. However, this error is sometimes apparent even when Tomcat has already …