Jul/110
Updating A Spring Tutorial
Open Netbeans.
New Web Application, Spring v2.5, changed default dispatcher to ‘springapp’
created a custom landing page – edit web.xml welcome page to make it the default.
Look at the springapp-servlet.xml and the indexController.
p:viewName="index" />
Apr/110
Spring / Netbeans – a missing context.xml file
So I’ve upgraded to Netbeans 7 recently, and had an issue that comes up when creating a new Spring MVC Web Application. That is, when I run the Tomcat application an error message appears – context.xml (The system cannot find the file specified).
Looking around on the internet it seems this may have been around for a while, so I was mystified as to why I hadn’t come across it before. However it seems like the kind of bug which stops occuring when I create my new Spring Web Application with another project already open in the Project Group. Don’t ask me why, and this may change in the future – but if you’re stuck on this it may be worth a try.
Feb/110
Perl Catalyst
I’ve been trying out a Perl MVC architecture called Catalyst. To get to grips with this I was handed a book by Jonathon Rockway which I have been trying to go through, though it’s five years old at the time of writing and maybe Catalyst has matured a bit since then.
However one issue I came across trying to get going with it was just the installation instructions. I ran the ‘apt-get install libcatalyst-perl’ command, but following this wasn’t enough to get the initial example up and running.
The error obtained was ‘Can’t locate Catalyst/Plugin/Static/Simple’ in @INC.
The fix was to also install libcatalyst-modules-perl. If you list all the catalyst packages you may also see some others you like.
I’ve ordered this book which seems to get good ratings….will see how it goes…. The Definitive Guide to Catalyst: Writing Extendable, Scalable and Maintainable Perl-Based Web Applications (Expert’s Voice in Web Development)
ADDENDUM – the book turned out to be a bit useless. For instance when it came to some out of date features – for example, a third party library that even the libraries author says DO NOT USE – the book just says – yeah, this example may not work.
The best source I found was the Catalyst tutorial on the website.
Nov/100
SSH Tunneling into a Web Server
“From a PC running Windows 7 or Linux I would like to connect to a linux server so I can view the web pages generated for a web application hidden behind a firewall.”
If this sounds like something you need to do then read on.
What we are going to do is implement SSH tunneling. SSH is used to ‘tunnel’ through the firewall. We then redirect port 80 on the web server through the SSH tunnel to port 1066 on the local machine.
You will need to have SSH login details to access your webserver.
On Windows
You will need to have Putty installed on your PC.
Start Putty.
Enter your SSH login URL as the host name, and if no alternative port has been specified for SSH, 22 as the host port.
In the left hand column go to Connection -> SSH -> Tunnels.
In the source port type 1066.
In the destination you will typically type ‘localhost:80′. However this may change if the web application you are accessing runs on a different port (e.g. Tomcat applications usually run on port 8080, and your own application may be something different), so you may have to type localhost:8080 to access Tomcat without going through the main webserver. In addition the localhost part of this may change if the webpages you are trying to access are on a different machine to the one you are trying to SSH into (e.g. you may have to type node2:80 if the machine you are logging into is connected to node2 as the machine you are running the web application on).
Click Add.
In the left hand column click ‘Session’ at the top.
Click ‘Save’ to save these settings.
Click Open.
You will be prompted for your username and password. (This opens a shell on your target machine so you can run linux command lines here).
To view the web application visit the following URL in your browser. http://localhost:1066/
On Linux
This can be done by opening a terminal window and typing in:
ssh -L 1066:localhost:80 username@websiteURL
In your webbrowser then going to http://localhost:1066 will give you the tracking system front end.
Jul/100
Including Custom Search Results In A WordPress Page
One website required certain pages to contain custom search results.
To do this I needed to have the following code. The main tricks here are to create a second query as well as the main page query using the WP_Query method, and that the parameter for such a query needs an s=… to let it know the phrase being supplied is a search term.
The get_post_meta() method allows extraction from the main page extra parameter list.
<?php
$query_string = get_post_meta($post->ID, ‘organism_class’, true) ;
$search = new WP_Query( "s=$query_string&showposts=5" ) ;
$search_posts = $search->query( "s=$query_string&showposts=5" ) ;
while ($search->have_posts()) : $search->the_post();
?>
<h4><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h4>
<?php the_content(); ?>
<?php endwhile; ?>
May/102
OpenOffice: Recovery Window keeps popping up for a deleted file
Calc, the OpenOffice.org spreadsheet program can sometimes crash for me when doing cut and paste. On one occasion I deleted the file I was working on.
Since then the recovery window pops up every time the program gets started and fails because the item doesn’t exist.
The solution is to delete the OpenOffice.org recovery file. Its located at the following subdirectory of the user data directory.
AppData\Roaming\OpenOffice.org\3\user\registry\data\org\openoffice\Office\Roaming.xcu
May/100
Windows 7: Deleting or Rename Files still appear in Windows Explorer until they are refreshed
I was experiencing a problem with Windows 7 Explorer in that deleting a file left behind a ghosted out version of the file in Explorer with the same name. I couldn’t actually do anything with this file as it was actually deleted (or moved if I had renamed it) but it was still listed until the folder was refreshed through the magic of the F5 key.
Finally when having to rename a load of these files I’d had enough. Googling the answer pointed me to some Microsoft forums which gave technologically advanced answers like registry editing and someone even suggesting recreating your user profile. This was from Microsoft!
Somewhere in one of the threads someone pointed out that this only happened when accessing the Documents through a ‘Library’. Libraries in Windows 7 are a useful feature to my personal account as they are a useful way of accessing a spread apart music or video collection via a single access point, especially given an external disc. But it seems some sort of caching issue creeps up with accessing folders in the Library.
The problem I had was that accessing something as u:\users\rishistar\My Documents\test\ still resolved to a Libraries path so I right clicked on each library and deleted each one. I don’t use them on my work account so this was fine for me. YMMV.
As a coda I did have to re-create my favourite shortcuts in the top left of the Explorer pane but that was no big deal.
May/100
Selecting MySQL rows within a Time Range for a Java Program
Earlier I discussed selecting rows from a table within a specified date range. What if you need to select rows from within a time range?
Again a SELECT statement with a WHERE clause is needed. The method below will give the statement for the start and end times of the statement. Unlike the earlier example this has a DateFormat to supply the String required to generate the SQL statement.
GregorianCalendar calStart = new GregorianCalendar() ;
calStart.set( Calendar.HOUR_OF_DAY, 18 ) ;
calStart.set( Calendar.MINUTE, 1 ) ;
String sql = "SELECT * FROM " + dbh.userTable.tableName +
" WHERE status=1 AND "
+ SQLStrings.getWhereBetweenDates( "signup_time", calStart ) ;
.....
public static String getWhereBetweenDates( String columnName, GregorianCalendar calStart)
{
GregorianCalendar now = new GregorianCalendar() ;
StringBuffer sb = new StringBuffer( columnName + " BETWEEN " ) ;
SimpleDateFormat df = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" ) ;
String beforeDateString = df.format( calStart.getTime() ) ;
String afterDateString = df.format( now.getTime() ) ;
sb.append( beforeDateString + " AND " + afterDateString ) ;
return sb.toString() ;
}
Note that the DateFormat String here was determined by what was present in the MySQL database for that particular column. YMMV – so if there are problems maybe check your database table to see what particular format that column takes.