<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Smartkey - Java Software Consultancy</title>
	<atom:link href="http://blog.smartkey.co.uk/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.smartkey.co.uk</link>
	<description></description>
	<lastBuildDate>Tue, 13 Dec 2011 15:03:46 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Adding the application name to links in a Web application</title>
		<link>http://blog.smartkey.co.uk/2011/12/adding-the-application-name-to-links-in-a-web-application/</link>
		<comments>http://blog.smartkey.co.uk/2011/12/adding-the-application-name-to-links-in-a-web-application/#comments</comments>
		<pubDate>Tue, 13 Dec 2011 15:03:46 +0000</pubDate>
		<dc:creator>Steve Neal</dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://blog.smartkey.co.uk/?p=958</guid>
		<description><![CDATA[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 [...]]]></description>
			<content:encoded><![CDATA[<p>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. </p>
<p>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 access index.jsp in the root directory of a WAR file called <code><strong>myapp.war</strong></code> running on Tomcat on the localhost you will need the following URL:</p>
<p><code>http://localhost:8080/<strong>myapp</strong>/index.jsp</code></p>
<p>When there are multiple applications running in the same Tomcat server, they must all have different names. </p>
<p>Any absolute URLs that you need to include in your application must include the applictions name at the start. For example, if in index.jsp we want to reference an image in &#8216;/images/banner.png&#8217; the absolute URL will be: &#8216;/myapp/images/banner.png&#8217;.</p>
<p>It is bad practice to hard code the application&#8217;s name in the URL as this may change for different deployments of the application. Instead, it may be added dynamically using the following scriptlet:</p>
<pre class="brush: php">
${pageContext.request.contextPath}
</pre>
<p>So, to add an img tag that refers to the banner image use:</p>
<pre class="brush: php">
&lt;img src=&quot;${pageContext.request.contextPath}/images/banner.png&quot;/&gt;
</pre>
<p>Alternatively, there are a number of custom tag libraries that will automatically do this for you. Spring MVC ships with such a tag:</p>
<pre class="brush: php">
&lt;spring:url value=&#039;/images/banner.png&#039;&gt;
</pre>
<p>this will achieve the same results as the scriptlet shown above but is simpler to remember when adding a number of links in your JSPs.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.smartkey.co.uk/2011/12/adding-the-application-name-to-links-in-a-web-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Identifying number of account logins on Sybase</title>
		<link>http://blog.smartkey.co.uk/2011/11/identifying-number-of-account-logins-on-sybase/</link>
		<comments>http://blog.smartkey.co.uk/2011/11/identifying-number-of-account-logins-on-sybase/#comments</comments>
		<pubDate>Thu, 03 Nov 2011 09:17:57 +0000</pubDate>
		<dc:creator>Steve Neal</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[sybase]]></category>

		<guid isPermaLink="false">http://blog.smartkey.co.uk/?p=955</guid>
		<description><![CDATA[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 &#039;%dblogin%&#039;
group by dbid, suid
order by count(suid)

]]></description>
			<content:encoded><![CDATA[<p>If you quickly need to see how many logins there are for each account in sybase, you can use this query:</p>
<pre class="brush: php">
select dbname=db_name(dbid),login=suser_name(suid), #connections=count(suid)
from master..sysprocesses
--where  suser_name(suid) like &#039;%dblogin%&#039;
group by dbid, suid
order by count(suid)
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.smartkey.co.uk/2011/11/identifying-number-of-account-logins-on-sybase/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quick formatting of Date using a Java String format expression</title>
		<link>http://blog.smartkey.co.uk/2011/10/quick-formatting-of-date-using-a-java-string-format-expression/</link>
		<comments>http://blog.smartkey.co.uk/2011/10/quick-formatting-of-date-using-a-java-string-format-expression/#comments</comments>
		<pubDate>Wed, 19 Oct 2011 12:00:59 +0000</pubDate>
		<dc:creator>Steve Neal</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Java Date Format]]></category>

		<guid isPermaLink="false">http://blog.smartkey.co.uk/?p=950</guid>
		<description><![CDATA[For quick reference, this is how you can format a date as:
dd/mm/yyyy at hh:mm:ss
System.out.printf(&#34;Date: %1$te/%1$tm/%1$tY at %1$tH:%1$tM:%1$tS%n&#34;, 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 &#8216;t&#8217; in each placeholder indicates a [...]]]></description>
			<content:encoded><![CDATA[<p>For quick reference, this is how you can format a date as:</p>
<p>dd/mm/yyyy at hh:mm:ss</p>
<pre class="brush: php">System.out.printf(&quot;Date: %1$te/%1$tm/%1$tY at %1$tH:%1$tM:%1$tS%n&quot;, new Date());</pre>
<p>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 &#8216;t&#8217; in each placeholder indicates a time conversion and the e, m, Y, H, M, S characters indicate what value should be taken from the new Date object for that time conversion.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.smartkey.co.uk/2011/10/quick-formatting-of-date-using-a-java-string-format-expression/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Searching for files in an Ant script</title>
		<link>http://blog.smartkey.co.uk/2011/09/searching-for-files-in-an-ant-script/</link>
		<comments>http://blog.smartkey.co.uk/2011/09/searching-for-files-in-an-ant-script/#comments</comments>
		<pubDate>Tue, 06 Sep 2011 11:17:19 +0000</pubDate>
		<dc:creator>Steve Neal</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Tool support]]></category>
		<category><![CDATA[Ant]]></category>
		<category><![CDATA[Ivy]]></category>

		<guid isPermaLink="false">http://blog.smartkey.co.uk/?p=934</guid>
		<description><![CDATA[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&#8217;ll demonstrate [...]]]></description>
			<content:encoded><![CDATA[<p>This is a simple technique for determining whether or not files matching a given pattern exist within your project. Unlike the <code>available</code> 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.</p>
<p>I&#8217;ll demonstrate the technique with an Ant target that I wrote to check whether Ivy had downloaded any jars that had the pattern SNAPSHOT in their name:</p>
<pre class="brush: php">
&lt;target name=&quot;ivy-count-snapshot-jars&quot; depends=&quot;init&quot; if=&quot;ivy.present&quot;&gt;
    &lt;resourcecount property=&quot;ivy.snapshot.count&quot;&gt;
        &lt;fileset dir=&quot;${ivylib.dir}&quot; includes=&quot;**/*SNAPSHOT*.jar&quot;/&gt;
    &lt;/resourcecount&gt;
    &lt;condition property=&quot;ivy.snapshot.present&quot;&gt;
        &lt;not&gt;
            &lt;equals arg1=&quot;${ivy.snapshot.count}&quot; arg2=&quot;0&quot;/&gt;
        &lt;/not&gt;
    &lt;/condition&gt;
&lt;/target&gt;

&lt;target name=&quot;ivy-check-snapshot-jars&quot;
        depends=&quot;ivy-count-snapshot-jars&quot;
        if=&quot;ivy.snapshot.present&quot;&gt;
     &lt;echo&gt;WARNING: Project uses ${ivy.snapshot.count} SNAPSHOT jar(s).&lt;/echo&gt;
&lt;/target&gt;
</pre>
<p>The first target does most of the work and is used to count the number of jar files with &#8216;SNAPSHOT&#8217; in their name; it also sets a property if the count is not zero.</p>
<p>The second target is the main one that should be used to perform the check. It depends on the first target (ensuring that the count is done first) and will only then run if the first target sets the &#8216;ivy.snapshot.present&#8217; property. Thus the warning message will only get echoed if there are snapshot jars in the project.    </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.smartkey.co.uk/2011/09/searching-for-files-in-an-ant-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding a thread timeout to methods in Java</title>
		<link>http://blog.smartkey.co.uk/2011/09/adding-a-thread-timeout-to-methods-in-java/</link>
		<comments>http://blog.smartkey.co.uk/2011/09/adding-a-thread-timeout-to-methods-in-java/#comments</comments>
		<pubDate>Thu, 01 Sep 2011 13:19:55 +0000</pubDate>
		<dc:creator>Steve Neal</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Java Programming]]></category>
		<category><![CDATA[Concurrency]]></category>
		<category><![CDATA[Concurrent]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Thread]]></category>

		<guid isPermaLink="false">http://blog.smartkey.co.uk/?p=924</guid>
		<description><![CDATA[When calling a method that could potentially take longer that you&#8217;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&#8217;d like an application to maintain a degree of liveness. I&#8217;ve used it recently in an application that needed [...]]]></description>
			<content:encoded><![CDATA[<p>When calling a method that could potentially take longer that you&#8217;d like to complete, it is possible to write code that will back out after a given time period. </p>
<p>This can happen in numerous circumstances where you&#8217;d like an application to maintain a degree of liveness. I&#8217;ve used it recently in an application that needed to run a number of external scripts; if the script does not complete, for whatever reason, the timeout ensures the the calling thread does not get blocked and the remaining scripts can be launched.</p>
<p>Here&#8217;s the basic idea:</p>
<pre class="brush: php">
public class TimeoutDemo {

    //maintains a thread for executing the doWork method
    private ExecutorService executor = Executors.newFixedThreadPool(1);

    public void doWork() {
        //perform some long running task here...
    }

    public void doWorkWithTimeout(int timeoutSecs) {

        //set the executor thread working
        final Future&lt;?&gt; future = executor.submit(new Runnable() {
            public void run() {
                try {
                    doWork();
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
            }
        });

        //check the outcome of the executor thread and limit the time allowed for it to complete
        try {
            future.get(timeoutSecs, TimeUnit.SECONDS);
        } catch (Exception e) {
            //ExecutionException: deliverer threw exception
            //TimeoutException: didn&#039;t complete within downloadTimeoutSecs
            //InterruptedException: the executor thread was interrupted

            //interrupts the worker thread if necessary
            future.cancel(true);

            log.warn(&quot;encountered problem while doing some work&quot;, e);
        }
    }
}
</pre>
<p>The doWork method is the one that will actually do some potentially long running work. The doWorkWithTimeout illustrates how the java.util.concurrent classes can be used to prevent the method from taking too long to complete. When calling the latter method, just specify the timeout period in minutes.</p>
<p>The trick here is that the actual work will be done by a dedicated worker thread. The calling thread will handle the timeout management and also handle any exceptions thrown by the worker.</p>
<p>Variations of this pattern can be used for methods that accept parameters (just make them final) and for ones that return values too (just return the value from the future.get(&#8230;) call).</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.smartkey.co.uk/2011/09/adding-a-thread-timeout-to-methods-in-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Count the processors on a Linux server</title>
		<link>http://blog.smartkey.co.uk/2011/06/count-the-processors-on-a-linux-server/</link>
		<comments>http://blog.smartkey.co.uk/2011/06/count-the-processors-on-a-linux-server/#comments</comments>
		<pubDate>Thu, 02 Jun 2011 14:46:16 +0000</pubDate>
		<dc:creator>Steve Neal</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Command]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[Unix]]></category>

		<guid isPermaLink="false">http://blog.smartkey.co.uk/?p=918</guid>
		<description><![CDATA[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 &#124; 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 [...]]]></description>
			<content:encoded><![CDATA[<p>If you need to see how many processors there are available on a Linu/Unix server, use the following command from your shell:</p>
<p><code>cat /proc/cpuinfo | grep processor</code></p>
<p>each of the processors will be listed in the output. For example, on a server I use the output looks like this:</p>
<p><code><br />
processor       : 0<br />
processor       : 1<br />
processor       : 2<br />
processor       : 3<br />
processor       : 4<br />
processor       : 5<br />
processor       : 6<br />
processor       : 7<br />
</code></p>
<p>So, on this server we can see there are 8 processors available.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.smartkey.co.uk/2011/06/count-the-processors-on-a-linux-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Deleting all files over a certain age on a Linux server</title>
		<link>http://blog.smartkey.co.uk/2011/05/deleting-files-over-a-certain-age-on-a-linux-server/</link>
		<comments>http://blog.smartkey.co.uk/2011/05/deleting-files-over-a-certain-age-on-a-linux-server/#comments</comments>
		<pubDate>Wed, 04 May 2011 15:38:58 +0000</pubDate>
		<dc:creator>Steve Neal</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Other]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://blog.smartkey.co.uk/?p=913</guid>
		<description><![CDATA[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.
]]></description>
			<content:encoded><![CDATA[<p>To delete files on a Linux server that are all over 3 days old, use this:<br />
<code><br />
find /log/ -type f -mtime -3 -exec rm {} \;<br />
</code><br />
This command will find all files in /log over 3 days old and will run the rm command for each of them.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.smartkey.co.uk/2011/05/deleting-files-over-a-certain-age-on-a-linux-server/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>What info can you get from an HttpServletRequest?</title>
		<link>http://blog.smartkey.co.uk/2011/02/httpservletrequestmethods/</link>
		<comments>http://blog.smartkey.co.uk/2011/02/httpservletrequestmethods/#comments</comments>
		<pubDate>Tue, 01 Feb 2011 13:17:44 +0000</pubDate>
		<dc:creator>Steve Neal</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Java Programming]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[JSP]]></category>
		<category><![CDATA[servlet]]></category>

		<guid isPermaLink="false">http://blog.smartkey.co.uk/?p=883</guid>
		<description><![CDATA[There are many methods on an HttpServletRequest, and if you&#8217;re anything like me, you&#8217;ll forget exactly what each of them returns. Rather than a long winded investigation into them all, here&#8217;s a sample URL:

https://localhost:8443/test/welcome?a=1&#038;b=2

The &#8216;/test&#8217; in the URL will map to a servlet called test. The servlet will dispatch the request to a JSP for [...]]]></description>
			<content:encoded><![CDATA[<p>There are many methods on an HttpServletRequest, and if you&#8217;re anything like me, you&#8217;ll forget exactly what each of them returns. Rather than a long winded investigation into them all, here&#8217;s a sample URL:<br />
<code><br />
https://localhost:8443/test/welcome?a=1&#038;b=2<br />
</code></p>
<p>The &#8216;/test&#8217; in the URL will map to a servlet called test. The servlet will dispatch the request to a JSP for rendering that has the following scriplet code in it:</p>
<pre class="brush: php">
RequestURL: &lt;%= request.getRequestURL() %&gt; &lt;br&gt;
RequestURI: &lt;%= request.getRequestURI() %&gt; &lt;br&gt;
QueryString: &lt;%= request.getQueryString() %&gt; &lt;br&gt;
ServletPath: &lt;%= request.getServletPath() %&gt; &lt;br&gt;
PathInfo: &lt;%= request.getPathInfo() %&gt; &lt;br&gt;
PathTranslated: &lt;%= request.getPathTranslated() %&gt;&lt;br&gt;
AuthType: &lt;%= request.getAuthType() %&gt; &lt;br&gt;
LocalAddress: &lt;%= request.getLocalAddr() %&gt; &lt;br&gt;
Method: &lt;%= request.getMethod() %&gt; &lt;br&gt;
RemoteUser: &lt;%= request.getRemoteUser() %&gt; &lt;br&gt;
</pre>
<p>this is the output generated:</p>
<pre class="brush: php">
RequestURL: https://localhost:8443/test/welcome
RequestURI: /test/welcome
QueryString: a=1&amp;b=2
ServletPath: /test
PathInfo: /welcome
PathTranslated: C:\projects\testproj\out\artifacts\testapp_war_exploded\welcome
AuthType: CLIENT_CERT
LocalAddress: 127.0.0.1
Method: GET
RemoteUser: Steve
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.smartkey.co.uk/2011/02/httpservletrequestmethods/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Implementing Flash Scope in Java Web Applications</title>
		<link>http://blog.smartkey.co.uk/2011/01/implementing-flash-scope-in-java-web-applications/</link>
		<comments>http://blog.smartkey.co.uk/2011/01/implementing-flash-scope-in-java-web-applications/#comments</comments>
		<pubDate>Mon, 17 Jan 2011 19:20:29 +0000</pubDate>
		<dc:creator>Steve Neal</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Java Programming]]></category>
		<category><![CDATA[Flash scope]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[JSP]]></category>
		<category><![CDATA[Request]]></category>
		<category><![CDATA[Session]]></category>
		<category><![CDATA[Spring MVC]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://blog.smartkey.co.uk/?p=828</guid>
		<description><![CDATA[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&#8217;t find anything that didn&#8217;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 [...]]]></description>
			<content:encoded><![CDATA[<p>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&#8217;t find anything that didn&#8217;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&#8217;ve included the code for this below so feel free to try it out.</p>
<h3>What is Flash Scope</h3>
<p>Flash scope is a useful part of many web frameworks. It allows the use of the <a href="http://en.wikipedia.org/wiki/Post/Redirect/Get">post/redirect/get</a> design pattern to alleviate many of the problems associated with handling multiple submits or resubmission of data in browser requests to the server.</p>
<p>Flash scope is an additional scope to those provided in a standard Java Web application (page, request, session and application). Any attributes held in flash scope will be available for the duration of the current request, and the subsequent request too.</p>
<h3>My Implementation</h3>
<p>To implement flash scope in my application, I added a servlet filter that checks for request attribute names starting with &#8216;<strong>flash.</strong>&#8216;. When it finds such an attribute, it ensures that it is made available in the subsequent request by temporarily storing it in the user&#8217;s session, and then reinstating it when the next request is received.</p>
<p>For example, to add a message to flash scope, just use the regular syntax for adding a request scoped attribute and let the fiter take care of it:</p>
<pre class="brush: php">
request.setAttribute(&quot;flash.message&quot;, &quot;Here is the news...&quot;);
</pre>
<p>The above attribute can then be accessed in the redirect target JSP using EL or scriptlet syntax (omitting the &#8216;<strong>flash.</strong>&#8216; prefix):</p>
<pre class="brush: php">
${message}
or
&lt;%= request.getAttribute(&quot;message&quot;)  %&gt;
</pre>
<p>Here&#8217;s the code for the filter:</p>
<pre class="brush: php">
import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;

/**
 * Ensures that any request parameters whose names start
 * with &#039;flash.&#039; are available for the next request too.
 */
public class FlashScopeFilter implements Filter {

    private static final String FLASH_SESSION_KEY = &quot;FLASH_SESSION_KEY&quot;;

    @SuppressWarnings(&quot;unchecked&quot;)
    public void doFilter(ServletRequest request, ServletResponse response,
					FilterChain chain) throws IOException, ServletException {

        //reinstate any flash scoped params from the users session
		//and clear the session
        if (request instanceof HttpServletRequest) {
            HttpServletRequest httpRequest = (HttpServletRequest) request;
            HttpSession session = httpRequest.getSession(false);
            if (session != null) {
                Map&lt;String, Object&gt; flashParams = (Map&lt;String, Object&gt;)
									session.getAttribute(FLASH_SESSION_KEY);
                if (flashParams != null) {
                    for (Map.Entry&lt;String, Object&gt; flashEntry : flashParams.entrySet()) {
                        request.setAttribute(flashEntry.getKey(), flashEntry.getValue());
                    }
                    session.removeAttribute(FLASH_SESSION_KEY);
                }
            }
        }

        //process the chain
        chain.doFilter(request, response);

        //store any flash scoped params in the user&#039;s session for the
		//next request
        if (request instanceof HttpServletRequest) {
            HttpServletRequest httpRequest = (HttpServletRequest) request;
            Map&lt;String, Object&gt; flashParams = new HashMap();
			Enumeration e = httpRequest.getAttributeNames();
            while (e.hasMoreElements()) {
                String paramName = (String) e.nextElement();
                if (paramName.startsWith(&quot;flash.&quot;)) {
                    Object value = request.getAttribute(paramName);
                    paramName = paramName.substring(6, paramName.length());
                    flashParams.put(paramName, value);
                }
            }
            if (flashParams.size() &gt; 0) {
                HttpSession session = httpRequest.getSession(false);
                session.setAttribute(FLASH_SESSION_KEY, flashParams);
            }
        }
    }

    public void init(FilterConfig filterConfig) throws ServletException {
        //no-op
    }

    public void destroy() {
        //no-op
    }
}
</pre>
<p>You can see from the listing, that the filter stores the flash scoped parameters in a session scoped  map called FLASH_SESSION_KEY. Before the request is processed by the filter chain, the flash attributes are retrieved from the session and added to request scope; after the chain has finished, any new flash scoped parameters are stored in a new session scoped map.</p>
<p>Note that the attributes have the &#8216;<strong>flash.</strong>&#8216; prefix removed when added to the session scoped map &#8211; this not only ensures that they can be accessed using their &#8217;short name&#8217;, but that they are only kept in the session for one extra request.</p>
<p>This approach is not Spring specific and should work with and Java Web framework. I&#8217;ve omitted the configuration for the filter as there are loads of examples of how to do this on the Internet already.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.smartkey.co.uk/2011/01/implementing-flash-scope-in-java-web-applications/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Finding tables and columns by name in a large Sybase database</title>
		<link>http://blog.smartkey.co.uk/2010/12/finding-tables-and-columns-in-sybase/</link>
		<comments>http://blog.smartkey.co.uk/2010/12/finding-tables-and-columns-in-sybase/#comments</comments>
		<pubDate>Tue, 07 Dec 2010 16:08:27 +0000</pubDate>
		<dc:creator>Steve Neal</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[sybase]]></category>

		<guid isPermaLink="false">http://blog.smartkey.co.uk/?p=822</guid>
		<description><![CDATA[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 &#039;%Sales%&#039;) and type = &#039;U&#039;

The sysobjects table stores data about various items in the database including tables (note that [...]]]></description>
			<content:encoded><![CDATA[<p>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. </p>
<pre class="brush: php">
select name,type from sysobjects where (name like &#039;%Sales%&#039;) and type = &#039;U&#039;
</pre>
<p>The sysobjects table stores data about various items in the database including tables (note that the type column is set to &#8216;U&#8217; for <strong>u</strong>ser tables).</p>
<p>To search for columns, you can use a similar query:</p>
<pre class="brush: php">
select name,object_name(id) from syscolumns where name like &#039;%currency%&#039;
</pre>
<p>This time, we&#8217;re querying a similar table specifically for columns. The ID column in this table is a foreigh key that refers to the primary key in the sysobjects table; thus allowing us to discover which table the column belongs to (done in this example using the object_name function).</p>
<p>This query will therefore return a list of all columns with the text &#8216;currency&#8217; in their name, and the tables to which they belong.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.smartkey.co.uk/2010/12/finding-tables-and-columns-in-sybase/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

