The Ruby on Rails framework provides some very handy XML features that make it easier to use database data for development and to provide XML-formatted database data for JavaScript applications. JavaScript also has built-in XML parsing capabilities, so it is easy to receive and parse XML-formatted data. But what if you want to access a Java™ application without deploying an additional server? This is JRuby's job. JRuby on Rails is a Java implementation of the Ruby on Rails framework, which brings the benefits of rails to Java programming by deploying Ruby applications to Java application servers.
Before you start
This tutorial is suitable for XML developers who are interested in using JRuby on Rails, Java Technologies, and databases. It's also for developers who want to use the JRuby on Rails framework to use the scaffolding feature, but can also use Java code to shorten development time.
About this tutorial
This tutorial shows how to improve Ajax applications with the help of Java application Server ibm®websphere®application server Express hosted JRuby on Rails and Java server Pages (JSP) technology The development efficiency. You will use the framework set by JRuby on Rails to access the movie Database through XML and use JSP technology to add new movies to the database and edit existing movies. In general, you will learn the following:
Installing WebSphere application Server Express
Install and set up the first JRuby project
Install the Goldspike plug-in into the JRuby project to deploy to the WebSphere application Server Express
Set up JRuby project to use Derby as a database
Implement a functioning JRuby on Rails 2.0.2 project and correctly send XML requests to AJAX clients
Develop JSP files to add and edit movie entries by using Ajax client-generated requests
Developing a pure Ajax client for managing movies
Deploy and test WebSphere application Server Express
To do this, you will develop a sample application for an online movie company where movie enthusiasts can manage, mark their online video libraries, and perform redirection operations. The Ajax application will receive XML-formatted traffic from JRuby on Rails and send XML-formatted traffic to the JSP application running the Java application Server instance.
Prerequisite
To learn this tutorial you need to download the following software:
WebSphere Application Server express-obtains a trial version of WebSphere Application Server Express from IBM (this tutorial uses V6.1). Use the WebSphere application Server as a fully functional Java application server to host JRuby on Rails Web applications. Note that you can use other application servers, such as Apache Tomcat or Apache Geronimo.
Jruby-jruby is a Ruby-oriented java-based interpreter that allows deployment to the Java application Server through the Goldspike plug-in and fully integrates with the Java library. This tutorial uses JRuby version 1.1.1 and Rails version 2.0.2. Rubygem (part of the JRuby package) will download and install Rails.
Database-The sample application needs to use the database to save and retrieve file entries. This tutorial uses the Derby included with WebSphere application Server Express, but you can use a different version. Derby is excellent because it is free and lightweight.
Having JSP knowledge and Rails technology can help you learn this tutorial, but not the necessary conditions.
Brief introduction
This section provides an overview of how to use the XML features of JRuby on Rails, JSP, and Ajax technologies, and how WebSphere application Server Express combines these features.
XML, Rails, Java, and Ajax Technologies
Common abbreviations
Ajax: Asynchronous JavaScript and XML (asynchronous JavaScript and XML)
DOM: Document Object Model
XML: Extensible Markup Language (extensible Markup Language)
With JRuby on Rails's built-in XML features, you can easily access XML-formatted database data. Because JRuby has better Java compatibility, you can use many other Java features. Thus, in a single AJAX application (which will be built in this tutorial), AJAX applications will reference both JRuby on Rails and JSP code to combine the strengths of both programming languages in a single WEB application. These strengths include Easy-to-use Ruby on Rails framework and powerful Java programming capabilities that can be used in JSP pages.
Next you'll learn how WebSphere application Server Express combines these features.
How WebSphere application Server Express combines these features
WebSphere Application Server Express is a Java Servlet container that enables you to deploy JRuby on Rails applications as packaged WAR files with the JRuby and Goldspike Plug-ins to Java Application Server. Not only that, you can also deploy JSP files within a ruby application and use them in conjunction with Ruby files.
Figure 1 shows the application that will be developed.
Figure 1. Sample Application Show