MCS 270 Spring 2014 Object-Oriented Software Development.

Slides:



Advertisements
Similar presentations
4 Copyright © 2005, Oracle. All rights reserved. Creating the Web Tier: Servlets.
Advertisements

 2002 Prentice Hall. All rights reserved. Chapter 9: Servlets Outline 9.1 Introduction 9.2 Servlet Overview and Architecture Interface Servlet and.
 Java  Python  Bigtable(Bt) is a distributed storage system for managing structured data that is designed to scale to a very large size.  Query Language.
An introduction to Java Servlet Programming
Liang, Introduction to Java Programming, Sixth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 34 Servlets.
June 1, 2000 Object Oriented Programming in Java (95-707) Advanced Topics 1 Lecture 10 Object Oriented Programming in Java Advanced Topics Servlets.
MCS 270 Spring 2014 Object-Oriented Software Development.
Chapter 4 Servlets Concept of Servlets (What, Why, and How) Servlet API Third-party tools to run servlets Examples of Using Servlets HTML tag with GET.
SE-2840 Dr. Mark L. Hornick1 Java Servlet-based web apps Servlet Architecture.
Java Servlets. What Are Servlets? Basically, a java program that runs on the server Basically, a java program that runs on the server Creates dynamic.
Gayle J Yaverbaum, PhD Professor of Information Systems Penn State Harrisburg.
Creating a Hello App Using Google App Engine. What are Google apps? Apps is an abbreviation for application. An app is a piece of software. It can run.
Platform as a Service (PaaS)
Google AppEngine. Google App Engine enables you to build and host web apps on the same systems that power Google applications. App Engine offers fast.
Google App Engine Google APIs OAuth Facebook Graph API
Amazon EC2 Quick Start adapted from EC2_GetStarted.html.
Google App Engine Danail Alexiev Technical Trainer SoftAcad.bg.
IT 210 The Internet & World Wide Web introduction.
Prof. A.R. Rele. What Is Google App Engine? Google App Engine lets users run web applications on Google's infrastructure. App Engine applications are.
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
Lecture 8 – Platform as a Service. Introduction We have discussed the SPI model of Cloud Computing – IaaS – PaaS – SaaS.
Google App Engine Chien-Chung Shen
Cloud Operating System Unit 11 Sever Technology II M. C. Chiang Department of Computer Science and Engineering National Sun Yat-sen University Kaohsiung,
Java Omar Rana University of South Asia. Course Overview JAVA  C/C++ and JAVA Comparison  OOP in JAVA  Exception Handling  Streams  Graphics User.
An program As a simple example of socket programming we can implement a program that sends to a remote site As a simple example of socket.
Chapter 5 Java Servlets. Objectives Explain the nature of a servlet and its operation Use the appropriate servlet methods in a web application Code the.
COMP 321 Week 7. Overview HTML and HTTP Basics Dynamic Web Content ServletsMVC Tomcat in Eclipse Demonstration Lab 7-1 Introduction.
Meet with the AppEngine Márk Gergely eu.edge. What is AppEngine? It’s a tool, that lets you run your web applications on Google's infrastructure. –Google's.
CSCI 6962: Server-side Design and Programming Web Services.
Web Server Programming 1. Nuts and Bolts. Premises of Course Provides general introduction, no in-depth training Assumes some HTML knowledge Assumes some.
Servlet Lifecycle Lec 28. Servlet Life Cycle  Initialize  Service  Destroy Time.
Chapter 3 Servlet Basics. 1.Recall the Servlet Role 2.Basic Servlet Structure 3.A simple servlet that generates plain text 4.A servlet that generates.
Java Servlets. Servlets When we run small Java programs within a browser these are referred to as Applets... And when we run small Java programs within.
Java Servlets & Java Server Pages Lecture July 2013.
Introduction to Google App Engine. 2 Google App Engine Does one thing well: running web apps Simple app configuration Scalable Secure.
Chapter 2 Web app architecture. High-level web app architecture  When a client request coming in and needs servlet to serve dynamic web content, what.
20-Nov-15introServlets.ppt Intro to servlets. 20-Nov-15introServlets.ppt typical web page – source Hello Hello.
MCS 270 Spring 2014 Object-Oriented Software Development.
Introduction to Server-Side Web Development Introduction to Server-Side Web Development Session II: Introduction to Server-Side Web Development with Servlets.
Copyright © 2002 ProsoftTraining. All rights reserved. Java Servlets.
CSIT 220 (Blum)1 Remote Procedure Calls Based on Chapter 38 in Computer Networks and Internets, Comer.
CSE 403 The Mythical Servlet Goals Introduce basic servlet terminology Formally introduce homework 2 Walkthrough of build & deployment Group discussion.
CSI 3125, Preliminaries, page 1 SERVLET. CSI 3125, Preliminaries, page 2 SERVLET A servlet is a server-side software program, Responds oriented other.
1 Introduction to Servlets. Topics Web Applications and the Java Server. HTTP protocol. Servlets 2.
JS (Java Servlets). Internet evolution [1] The internet Internet started of as a static content dispersal and delivery mechanism, where files residing.
Paperless Timesheet Management Project Anant Pednekar.
Introduction to Servlets Allen Day. Notes This is a training NOT a presentation Please ask questions Prerequisites.
Module: Software Engineering of Web Applications Chapter 2: Technologies 1.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
CSI 3125, Preliminaries, page 1 SERVLET. CSI 3125, Preliminaries, page 2 SERVLET A servlet is a server-side software program, written in Java code, that.
ICM – API Server & Forms Gary Ratcliffe.
How CGI and Java Servlets are Run By David Stein 14 November 2006.
COMP2322 Lab 4 Socket Programming Toby Lam March 2, 2016.
CS 562 Advanced Java and Internet Application Computer Warehouse Web Application By Team Alpha :-  Puja Mehta (102163)  Mona Nagpure (102147)
CS122B: Projects in Databases and Web Applications Spring 2017
Introduction to Servlets
Platform as a Service (PaaS)
CS122B: Projects in Databases and Web Applications Winter 2017
Platform as a Service (PaaS)
Platform as a Service (PaaS)
z/Ware 2.0 Technical Overview
Servlet Fudamentals.
Java Servlets By: Tejashri Udavant..
Platform as a Service.
Google App Engine Danail Alexiev
Chapter 26 Servlets.
CS122B: Projects in Databases and Web Applications Winter 2018
CS122B: Projects in Databases and Web Applications Spring 2018
Google App Engine Ying Zou 01/24/2016.
CS122B: Projects in Databases and Web Applications Winter 2019
Presentation transcript:

MCS 270 Spring 2014 Object-Oriented Software Development

GUSTAVUS ADOLPHUS COLLEGEgustavus.edu Today’s schedule GAE – Google App Engine Modules User Service Blob Service MCS 270 Object-Oriented Software Development

GUSTAVUS ADOLPHUS COLLEGEgustavus.edu Overview Google App Engine is: - runtime platform that provides web application hosting, data storage, and high-speed networking - infrastructure (servers + storage ) at Google MCS 270 Object-Oriented Software Development

GUSTAVUS ADOLPHUS COLLEGEgustavus.edu Overview GAE Advantages: Does one thing well: running web apps App Engine handles HTTP(S) requests, nothing else Simple (relatively) app configuration Automatic Scaling to Application Needs Secure Easy on budget: Pay only for what you use (small apps are free) MCS 270 Object-Oriented Software Development

GUSTAVUS ADOLPHUS COLLEGEgustavus.edu GAE Runtime Environment Java: Java 7 Virtual Machine (JVM) Java Servlet interface for client-server Python: Python 2.7 Go Java or Python? Python: powerful python syntax, library, shorter code Java: can use Java Data Objects (JDO) and Java Persistance API (JPA) MCS 270 Object-Oriented Software Development

GUSTAVUS ADOLPHUS COLLEGEgustavus.edu MCS 270 Object-Oriented Software Development

GUSTAVUS ADOLPHUS COLLEGEgustavus.edu GAE Sandbox Applications run in a secure environment - limited access to underlying OS Plus - App will NEVER affect other applications on the same server Minuses - Cannot spawn additional processes or threads Cannot make arbitrary network connections Only read its own code and resource files and cannot create or modify files MCS 270 Object-Oriented Software Development

GUSTAVUS ADOLPHUS COLLEGEgustavus.edu GAE Sandbox Restrictions - App can only access other computers on the Internet through URL fetch and services. - App interaction to server only by HTTP (or HTTPS) requests on the standard ports - Applications cannot write to the file system MCS 270 Object-Oriented Software Development

GUSTAVUS ADOLPHUS COLLEGEgustavus.edu GAE Services URLFetch – fetch web resources/services (servlets) Images – manipulate images: resize, rotate, flip, crop User Services: Google Accounts Mail XMPP – instant messages Task Queue – message queue; allow integration with non-GAPPs Datastore – managing data objects Blobstore – large files, much larger than objects in datastore MCS 270 Object-Oriented Software Development

GUSTAVUS ADOLPHUS COLLEGEgustavus.edu GAE User Services Google App Engine service based on Google infrastructure Accessible by applications using libraries included with GAE SDK. Provides integration with Google user accounts. Users use existing Google accounts to sign in to Application MCS 270 Object-Oriented Software Development

GUSTAVUS ADOLPHUS COLLEGEgustavus.edu GAE User Services Demo MCS 270 Object-Oriented Software Development

GUSTAVUS ADOLPHUS COLLEGEgustavus.edu Program Flow – GusList.java public void onModuleLoad() { glView.setController(GusList.this); homeURL = Window.Location.getHref(); clientModelService.setAppBaseURL(homeURL, new AsyncCallback () { public void onFailure(Throwable caught) {return;} public void onSuccess(String result) {}}); clientModelService.isUserLoggedIn( new AsyncCallback () { public void onFailure(Throwable caught) {return;} public void onSuccess(Boolean result) { if(result) glView.viewWelcomePage(); else glView.setWindow("../GusListWelcome.html"); }});} MCS 270 Object-Oriented Software Development

GUSTAVUS ADOLPHUS COLLEGEgustavus.edu Program Flow – GusListView.java public void setWindow(String url) { Window.Location.replace(url); } MCS 270 Object-Oriented Software Development

GUSTAVUS ADOLPHUS COLLEGEgustavus.edu Program Flow – GusListWelcome.html Welcome to GusList - the Gustavus on-line classified ad system. To start checking out the latest ads from the coolest students, please login. If you are new to the system, you will need to create a Google account to login. MCS 270 Object-Oriented Software Development

GUSTAVUS ADOLPHUS COLLEGEgustavus.edu Program Flow – web.xml LoginService edu.gac.mcs270.hvidsten.guslistgae.server.LoginService LoginService /guslist/loginservice MCS 270 Object-Oriented Software Development

GUSTAVUS ADOLPHUS COLLEGEgustavus.edu Program Flow - LoginService public class LoginService extends HttpServlet { public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { UserService userService = UserServiceFactory.getUserService(); User user = userService.getCurrentUser(); if (user != null) { resp.setStatus(HttpServletResponse.SC_SEE_OTHER); resp.setHeader("Location", "../GusList.html”); } else { String logInLink = userService.createLoginURL("../GusList.html”); resp.setStatus(HttpServletResponse.SC_SEE_OTHER); resp.setHeader("Location", logInLink); }}} MCS 270 Object-Oriented Software Development

GUSTAVUS ADOLPHUS COLLEGEgustavus.edu Login by GAE MCS 270 Object-Oriented Software Development Note: Login and logout pages are handle by GAE automatically, but the workflow is different : Run on local – It will simulate Google Accounts sign-in page (no password authentication). Run on GAE – It will redirect to actual Google Account login screen.

GUSTAVUS ADOLPHUS COLLEGEgustavus.edu Program Flow – After Login returns to GusList.html MCS 270 Object-Oriented Software Development Basically Empty – filled in by GusListView

GUSTAVUS ADOLPHUS COLLEGEgustavus.edu RPC vs HTTP Servlets HTTP – Simplest way to retrieve data from server. Data can be anything (text, HTML, XML, binary data, etc). Programmer must make sense of data. RPC – Easiest way to tranfer Java objects from server client. Data can only contain Serializable objects. Programmer knows exactly what form data is in. MCS 270 Object-Oriented Software Development

GUSTAVUS ADOLPHUS COLLEGEgustavus.edu RPC “A remote procedure call (RPC) is an inter-process communication that allows a program to cause a procedure to execute in another address space (commonly on another computer on a shared network) without the programmer explicitly coding the details for this remote interaction. When the software in question uses object-oriented principles, RPC is called remote invocation or remote method invocation.” (Wikipedia) MCS 270 Object-Oriented Software Development

GUSTAVUS ADOLPHUS COLLEGEgustavus.edu HTTP Request / Response Cycle Browser Web Server HTTP Request HTTP Response IE, FireFox, Chrome,Safari MCS 270 Object-Oriented Software Development

GUSTAVUS ADOLPHUS COLLEGEgustavus.edu HTTP Request / Response Cycle Browser Web Server HTTP Request HTTP Response IE, FireFox, Chrome,Safari MCS 270 Object-Oriented Software Development GET /index.html.. Welcome to my application....

GUSTAVUS ADOLPHUS COLLEGEgustavus.edu RPC vs HTTP Servlets LoginService - Transfers actual URL’s, comes from GET request. Must be HTTP servlet. MCS 270 Object-Oriented Software Development

GUSTAVUS ADOLPHUS COLLEGEgustavus.edu Program Flow - LoginService public class LoginService extends HttpServlet { public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { UserService userService = UserServiceFactory.getUserService(); User user = userService.getCurrentUser(); if (user != null) { resp.setStatus(HttpServletResponse.SC_SEE_OTHER); resp.setHeader("Location", "../GusList.html”); } else { String logInLink = userService.createLoginURL("../GusList.html”); resp.setStatus(HttpServletResponse.SC_SEE_OTHER); resp.setHeader("Location", logInLink); }}} MCS 270 Object-Oriented Software Development

GUSTAVUS ADOLPHUS COLLEGEgustavus.edu GAE Blob Service Blobstore API - mechanism to store “blobs” of information Blob can be up to 50MB in size (typically large files –video, images) Datastore vs Blob Service Datastore – data size limited to 1mb, Access only through a GAE app. Blob Service – Size up to 50mb. Cheaper than Datastore. Data can be served directly as url access. Designed for images – can do image transformations in place. MCS 270 Object-Oriented Software Development

GUSTAVUS ADOLPHUS COLLEGEgustavus.edu GAE Blob Service Demo MCS 270 Object-Oriented Software Development

GUSTAVUS ADOLPHUS COLLEGEgustavus.edu Program Flow - GusListView FormPanel submitFormPanel // The submitFormPanel, when submitted, will trigger an HTTP call to the // servlet. The following parameters must be set submitFormPanel.setEncoding(FormPanel.ENCODING_MULTIPART); submitFormPanel.setMethod(FormPanel.METHOD_POST); // Set Names for the text boxes so that they can be retrieved from the // HTTP call as parameters nameTextbox.setName("name"); titleTextbox.setName("title"); descrText.setName("description"); priceTextbox.setName("price"); upload.setName("upload"); MCS 270 Object-Oriented Software Development

GUSTAVUS ADOLPHUS COLLEGEgustavus.edu Program Flow - GusListView submitButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { control.handlePostFromSubmitForm(submitFormPanel); }}); MCS 270 Object-Oriented Software Development

GUSTAVUS ADOLPHUS COLLEGEgustavus.edu Program Flow - GusList public void handlePostFromSubmitForm(final FormPanel submitFormPanel) { blobService.getBlobStoreUploadUrl( new AsyncCallback () { public void onSuccess(String result) { // Set the form action to the newly created blobstore upload URL submitFormPanel.setAction(result.toString()); // Submit the form to complete the upload // This causes activation of an upload HTTP servlet submitFormPanel.submit(); } public void onFailure(Throwable caught) { glView.sendErrorMessage("Upload Failed"); }}); } MCS 270 Object-Oriented Software Development

GUSTAVUS ADOLPHUS COLLEGEgustavus.edu Program Flow - BlobService public class BlobServiceImpl extends RemoteServiceServlet implements BlobService { //Start a GAE BlobstoreService session BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService(); //Generate a Blobstore Upload URL public String getBlobStoreUploadUrl() { // Map the BlobService UploadURL to the // HTTP servlet which will be called when // submitting the FormPanel (see web.xml for servlet def) return blobstoreService.createUploadUrl("/guslist/uploadservice"); } MCS 270 Object-Oriented Software Development

GUSTAVUS ADOLPHUS COLLEGEgustavus.edu Program Flow - SubmitPostHTTPService public class SubmitPostHTTPServiceImpl extends HttpServlet { //Start Blobstore BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService(); //Override the doPost method to store the Blob's public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { Map blobs = blobstoreService.getUploadedBlobs(req); BlobKey blobKey = blobs.get("upload"); MCS 270 Object-Oriented Software Development

GUSTAVUS ADOLPHUS COLLEGEgustavus.edu Program Flow - SubmitPostHTTPService //Get the parameters from the request to post the ad String name = req.getParameter("name"); String title = req.getParameter("title"); String descr = req.getParameter("description"); double price = Double.valueOf(req.getParameter("price")); //Map the ImageURL to the blobservice servlet, which will serve the image String url = "/guslist/blobservice?blob-key=" + blobKey.getKeyString(); PostData post = new PostData(title,descr,price, url, new Seller(name), null); GusListModel.storePost(post); }} MCS 270 Object-Oriented Software Development