I started searching google for sample code that might help me write a simple "put" , "get" program, finally got one from Sun itself.
Assumptions
You are expected to have some basic understanding of messaging concepts.
H/W and S/W
This uses IBM MQ Series and the middleware, and tomcat servlet container.
What the program does

As shown above, this sample application has a text box where user can type something and on clicking "put" button, message will be send to a queue.
Clicking on "get" button will retrieve the first message in the queue and the message will be shown in the text box.
Logic for putting the message into queue