Presentation is loading. Please wait.

Presentation is loading. Please wait.

Technology Comparison between JSP and Rails By Kwan Shing Yuen CS491B.

Similar presentations


Presentation on theme: "Technology Comparison between JSP and Rails By Kwan Shing Yuen CS491B."— Presentation transcript:

1 Technology Comparison between JSP and Rails By Kwan Shing Yuen CS491B

2 Description Comparison two programming languages by creating online store web site Java (OO language) and JSP(J2EE) Ruby (Scripting language) and Rails

3 JSP version ( JSP version) Programming Language:Java 1.5 Development tool:Sun J2EE™ Development Kit 5.0 Integrated Development Environment:TextPad 4.7.3 32-bit Development Platform:Microsoft Windows XP Web Server: Tomcat ( port 8080 ) Database:MYSQL

4 Rails version ( Rails version) Programming Language:Ruby (ruby1.8.2-15) Development tool:Ruby on Rails framework Integrated Development Environment:TextPad 4.7.3 32-bit Edition Development Platform:Microsoft Windows XP Web Server:WEBrick 1.3.1 ( port 3000 ) Database:MYSQL

5 Book Store Feature Book search Shopping Cart Check Out Login ( admin ) Pending and Shipped Order List

6 Database

7 Database (Cont.)

8

9

10 Structure overview

11

12 Software Architecture MVC –Model –View –Controller

13 JSP Models –User.java –MyBook.java, MyBooks.java –CartItem.java, CartItem.java Views –userM.jsp –adminM.jsp –MyCart.jsp ……… Controller –Book_Controller.java

14 Rails Models –Book.rb –Order.rb –Cart.rb Views –Search.rhtml –Display_cart.rhtml –List.rhtml …………. Controller – book_Controller.rb, admin_Controller.rb, login_Controller.rb

15 Syntax Variable In Java: MyBook temp = new MyBook() In Ruby: @temp ( we don’t need to specific the type, it can be a object) eg. @temp = Book.new

16 Syntax (Cont.) Parameter In JSP: req.getParameter("id") -> in a String type In Rails: params[:id] -> can be any type

17 Syntax (Cont.) HyperLink In JSP: ISBN In Rails: "show", :id => @bookss.id %>

18 Development JSP has to code line by line JSP has more code in getting data from database

19 Rails It has a scaffold autogenerated Less code of getting data in MYSQL –Auto mapping to the database Create table books ( id int ………….. Book.rb –class Book < ActiveRecord::Base……. –…… –end

20 DEMO >rails depot create table products( id int not null auto_increment, name varchar(10) not null, primary key(id)); database connection > ruby script.generate scaffold Product Admin

21 Search in database Search in Database: In JSP: // Result rs= stmt.executeQuery("select * from books where id = 2"); while( rs.next() ) { int id = rs.getInt(“id”); } // Result rs= stmt.executeQuery("select * from books where isbn = ‘16349827’"); while( rs.next() ) { String isbn = rs.getInt(“isbn”); } //

22 Search in database In Rails: @id = 2 book = Book.find(@id) @ISBN = 16349827 @bookss = Book.find_by_ISBN @ ISBN

23 JSP and Rails Demo


Download ppt "Technology Comparison between JSP and Rails By Kwan Shing Yuen CS491B."

Similar presentations


Ads by Google