Thursday, December 31, 2009

Restful Web Services using Restlet Framework

Restlet framework is a Restful Web Service framework written Java.

However, Microsoft has worked with the team behind Restlet and has enabled interoperability between Azure and Restlet.


Other big companies like Google also use the Restlet framework for writing Web Services in a Restful way. I always lean towards projects that are well documented and the Restlet framework has some good documentation including examples, tutorials, and api documents. In addition, if you want to integrate a Spring Web project with Restlet, here is a good write up,


If your website leverages ajax via javascript, one of the nice things with Restlets is that you can easily call your Restful Web Services using javascript.

Restlets has implemented lots of extensions, for example if you want to write a smartphone app in android to call Restful Web Services, Restlets has an extension for this.

Restlet is extremely flexible and can be called from either a Web client or Web server code.

Thursday, December 17, 2009

Spring MVC with SiteMesh Decoration Framework and Velocity Templates

Most developers hate to repeat themselves, so they like to reuse as much code as possible. The folks at who also brought you Quartz developed Sitemesh to utilize the Gang of Four pattern composition.
In short, SiteMesh is a web-page layout and decoration framework. It allows you to
reuse your layouts (header and footer for example) throughout your site, so that
you site has a consistent look and feel.

The general documentation at the SiteMesh Site site is quite good but I needed to utilize Sitemesh in the following specific scenario, I am using Spring MVC and Velocity Templates.

Since the general install documentation, installation instructions is very good, I will not repeat it here. Once you have downloaded and setup your web project, you will have 3 xml config that you will be dealing with, web.xml, sitemesh.xml, and decorators.xml. In my case I am using Spring MVC and Velocity, so I need to customize my web.xml configuration to handle this setup. Here is how my web.xml is configured:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4"






<!--Used to Enable Spring MVC -->







If you followed the SiteMesh Install steps at their site and then customized your
web.xml for your Spring MVC web project, you should now have SiteMesh configured correctly to use with Spring MVC and Velocity.
Important to note in your decorators.xml since you are using Velocity,
you will be using *.vm decorator files, here is an example decorators.xml file:

<?xml version="1.0" encoding="ISO-8859-1"?>
<decorators defaultdir="/decorators">
<!-- Any urls that are excluded will never be decorated by Sitemesh -->

<decorator name="default" page="default.vm">