Steve Neal

This user hasn't shared any biographical information

Homepage: http://www.smartkey.co.uk


Posts by Steve Neal

Adding the application name to links in a Web application

December 13, 2011 - 3:03 pm

Posted in Development | No Comments

Application servers can run a number of applications. A single Tomcat instance, for example, will create a separate web application for each WAR file it finds in its webapps directory.
The applications will be named the same as their WAR files and can be accessed using URLs that start with that name. For example, to [...]

Identifying number of account logins on Sybase

November 3, 2011 - 9:17 am

Tags:
Posted in Development | No Comments

If you quickly need to see how many logins there are for each account in sybase, you can use this query:

select dbname=db_name(dbid),login=suser_name(suid), #connections=count(suid)
from master..sysprocesses
–where suser_name(suid) like '%dblogin%'
group by dbid, suid
order by count(suid)

Quick formatting of Date using a Java String format expression

October 19, 2011 - 1:00 pm

Tags:
Posted in Development | No Comments

For quick reference, this is how you can format a date as:
dd/mm/yyyy at hh:mm:ss
System.out.printf("Date: %1$te/%1$tm/%1$tY at %1$tH:%1$tM:%1$tS%n", new Date());
The % characters mark a placeholders for String content, the 1$ indicates that the first vararg should be used for each placeholder (there is only one varag value supplied), the letter ‘t’ in each placeholder indicates a [...]

Searching for files in an Ant script

September 6, 2011 - 12:17 pm

Tags: ,
Posted in Development, Tool support | No Comments

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 [...]

Adding a thread timeout to methods in Java

September 1, 2011 - 2:19 pm

Tags: , , , ,
Posted in Development, Java Programming | No Comments

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 [...]

Count the processors on a Linux server

June 2, 2011 - 3:46 pm

Tags: , ,
Posted in Linux | No Comments

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 [...]

Deleting all files over a certain age on a Linux server

May 4, 2011 - 4:38 pm

Tags:
Posted in Linux, Other | 2 Comments

To delete files on a Linux server that are all over 3 days old, use this:

find /log/ -type f -mtime -3 -exec rm {} \;

This command will find all files in /log over 3 days old and will run the rm command for each of them.

What info can you get from an HttpServletRequest?

February 1, 2011 - 1:17 pm

Tags: , ,
Posted in Development, Java Programming | No Comments

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 [...]

Implementing Flash Scope in Java Web Applications

January 17, 2011 - 7:20 pm

Tags: , , , , , ,
Posted in Development, Java Programming | 3 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 [...]

Finding tables and columns by name in a large Sybase database

December 7, 2010 - 4:08 pm

Tags: ,
Posted in Databases | No Comments

When working with a large Sybase database, especially one that you are not too farmiliar with, the following SQL snippets can be really useful for finding your way around.

select name,type from sysobjects where (name like '%Sales%') and type = 'U'

The sysobjects table stores data about various items in the database including tables (note that [...]