1 / 23

Technology Comparison between JSP and Rails

CS491B. Technology Comparison between JSP and Rails. By Kwan Shing Yuen. Description. Comparison two programming languages by creating online store web site Java (OO language) and JSP(J2EE) Ruby (Scripting language) and Rails. JSP version. ( JSP version) Programming Language: Java 1.5

briana
Download Presentation

Technology Comparison between JSP and Rails

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  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. Database (Cont.)

  9. Database (Cont.)

  10. Structure overview

  11. Software Architecture • MVC • Model • View • Controller

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

  13. 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

  14. 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

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

  16. Syntax (Cont.) HyperLink In JSP: <a href="show.jsp?id=3">ISBN</a> In Rails: <%= link_to @bookss.ISBN, :action => "show", :id => @bookss.id %>

  17. Development • JSP has to code line by line • JSP has more code in getting data from database

  18. 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

  19. 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

  20. 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”); • } • //

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

  22. JSP and RailsDemo

More Related