Skip to main content


developerWorks  >  XML | Open source | Java technology | WebSphere  >

Use JRuby on Rails and XML to supercharge Ajax with a Java Application Server

Learn how XML can improve the efficiency of your JRuby on Rails and Ajax development

developerWorks

Level: Intermediate

Tyler Anderson (tyleranderson5@yahoo.com), Freelance writer, Backstop Media

27 May 2008

Register now or sign in using your IBM ID and password.

The Ruby on Rails framework has handy XML features that will make developing with and serving database data in XML format to your JavaScript applications easier than ever. JavaScript also has built-in XML parsing capabilities that make it a snap to receive and parse data in XML format. But what if you now want to hook into Java™ applications without having to deploy another server? That's where JRuby comes in. JRuby on Rails is the Java implementation of the Ruby on Rails framework, bringing the benefits of Rails to Java programming by allowing deployment of Ruby apps to Java application servers. In this tutorial, you'll develop a JRuby on Rails application deployable to a Java application server that will serve database data in XML format to an Ajax client that you'll build for film lovers to manage their online films database. You'll also deploy a couple of Java Server Pages pages on the same Java application server to assist the Ajax client in adding and updating films.

In this tutorial

This tutorial shows how to develop Ajax applications more efficiently with the help of JRuby on Rails and Java Server Pages (JSP) technologies hosted on a Java application server, IBM® WebSphere® Application Server Express. You'll use the framework set up by JRuby on Rails to give simple access, through XML, to your database of films, and you'll use JSP technology to add new films to and edit existing films in the database.

You'll develop an example application for the online film industry where lovers of film can manage, tag, and be redirected to their library of online videos. The Ajax application will receive communications in XML format from JRuby on Rails and send XML communications to JSP applications running a single Java application server instance.


Objectives

  • Install WebSphere Application Server Express

  • Install and set up your first JRuby project

  • Install the Goldspike plugin to your JRuby project for deployment to WebSphere Application Server Express

  • Set up your JRuby project to use Derby as the database

  • Get a working JRuby on Rails 2.0.2 project to properly send XML requests to the Ajax client

  • Develop JSP files to handle adding and editing film entries by utilizing XML requests made by the Ajax client

  • Develop an all-Ajax client to manage your films

  • Deploy and test on WebSphere Application Server Express

Prerequisites

This tutorial is recommended for XML developers interested in using JRuby on Rails, Java technology, and a database. It's also for those XML developers who wish to reduce their development time as they leverage the JRuby on Rails framework to use scaffolding without having to sacrifice the option of also using Java code.

Knowledge of JSP and Rails technology is useful for this tutorial, but not required.


System requirements

You will need JavaScript enabled in your browser.

For this tutorial you'll need the following downloads:

  • WebSphere Application Server Express —Get a trial version of WebSphere Application Server Express from IBM (this tutorial uses V6.1). You'll use WebSphere Application Server as a full featured Java application server to host your JRuby on Rails Web application. However, please note that you can use any application server, such as Apache Tomcat or Apache Geronimo.
  • JRuby —JRuby is a Java-based interpreter for Ruby, allowing deployment to Java application servers through the Goldspike plugin with full integration with Java libraries. This tutorial uses JRuby version 1.1.1, and Rails version 2.0.2. Rails will be downloaded and installed by RubyGem, which is part of the JRuby package.
  • Database—The example application requires a database to store and retrieve film entries. This tutorial uses the version of Derby that comes with WebSphere Application Server Express, though you can use any version. Derby is nice because it's free and lightweight.


Duration

1 hour





Formats

html, pdf


Share this....

digg Digg this story del.icio.us del.icio.us Slashdot Slashdot it!


Back to top


Document options

Document options requiring JavaScript are not displayed


My developerWorks needs you!

Connect to your technical community