lab session google application engine - gae
TRANSCRIPT
![Page 1: Lab session Google Application Engine - GAE](https://reader033.vdocuments.us/reader033/viewer/2022052805/628f4cad3c1e2448a9074315/html5/thumbnails/1.jpg)
Lab session Google Application Engine - GAE
Navid Nikaein
![Page 2: Lab session Google Application Engine - GAE](https://reader033.vdocuments.us/reader033/viewer/2022052805/628f4cad3c1e2448a9074315/html5/thumbnails/2.jpg)
Available projects
Project Company contact
Mobile Financial Services Innovation TIC Vasco Mendès
Bluetooth low energy Application on Smart Phone
ST semiconductor Lionel Chastion
Proximity Traffic Safety Warning
Eurecom Jerome Haerri
E-mobility Proximity Charging Service
Eurecom Jerome Haerri
Clustering usage pattern of mobile devices
EURECOM Soumya Datta
Mobile Travel Assistant 3Hpartner Stefano Crosta
25/12/2013 - - p 2
![Page 3: Lab session Google Application Engine - GAE](https://reader033.vdocuments.us/reader033/viewer/2022052805/628f4cad3c1e2448a9074315/html5/thumbnails/3.jpg)
From the Last Session
From offline to walled-garden to a true-online access
Wireless system and technology evolution
Run time environments OS war Mobile OS vs application-specific execution environment
App store
25/12/2013 - - p 3
![Page 4: Lab session Google Application Engine - GAE](https://reader033.vdocuments.us/reader033/viewer/2022052805/628f4cad3c1e2448a9074315/html5/thumbnails/4.jpg)
Overall Interactions
Client-side Programming
Clients (browsers)
HTTP Server
HTTP for transport
URL/URI for addressing
HTML for display
XML for Data
WML
(X)HTML XML
XML dialects
XSLT (Transformations)
FML
XHTML
Server-side Programming
DB Access, Web Services
Source: P. Michiardi, S. Crosta
4
![Page 5: Lab session Google Application Engine - GAE](https://reader033.vdocuments.us/reader033/viewer/2022052805/628f4cad3c1e2448a9074315/html5/thumbnails/5.jpg)
Protocol Interaction
5
HTTP
TCP
IP
L1/L2
Air Interface
Client
Router
IP
L1/L2 SONET interface
IP
SONET interface
Ethernet interface
SONET link
HTTP
TCP
IP
Ethernet interface
Web server
Ethernet
Router
IP packet IP packet IP packet
TCP segment
HTTP message
Source: P. Michiardi
![Page 6: Lab session Google Application Engine - GAE](https://reader033.vdocuments.us/reader033/viewer/2022052805/628f4cad3c1e2448a9074315/html5/thumbnails/6.jpg)
Client- vs Server-side Programming Client-side
HTML and script sent to client
Script processed before display
Script visible to client
Server-side Script processed before
sending HTML to client
Client receives and displays processed HTML
Script hidden from client <HTML>
<SCRIPT> echo "Hello"
</SCRIPT>
<HTML> <SCRIPT>
echo "Hello" </SCRIPT>
<HTML> Hello
<HTML> <SCRIPT>
echo "Hello" </SCRIPT>
<HTML> Hello
<HTML> Hello
Source: P. Michiardi, S. Crosta
6
![Page 7: Lab session Google Application Engine - GAE](https://reader033.vdocuments.us/reader033/viewer/2022052805/628f4cad3c1e2448a9074315/html5/thumbnails/7.jpg)
Servlet job and life cycle
Extend the server capabilities by means of request-response programming model
Usage Read and store data and process
request from the client Send data / response back to the
client Build a dynamic content Manage state information
See http://en.wikipedia.org/wiki/Java_Servlet &
http://en.wikibooks.org/wiki/J2EE_Programming/Servlet
25/12/2013 - - p 7
![Page 8: Lab session Google Application Engine - GAE](https://reader033.vdocuments.us/reader033/viewer/2022052805/628f4cad3c1e2448a9074315/html5/thumbnails/8.jpg)
Servlet
Servlet container Manage the life cylce Dispatch/mapping the URL
Servlet API Packege : javax.servlet.*
Different data format may exist Html, xml, json
25/12/2013 - - p 8
![Page 9: Lab session Google Application Engine - GAE](https://reader033.vdocuments.us/reader033/viewer/2022052805/628f4cad3c1e2448a9074315/html5/thumbnails/9.jpg)
Project structure and files
Project structure
src/
war/ WEB-INF/
– appengine-generated/ – classes/ – lib/ – appengine-web.xml – web.xml
Web.xml <servlet> <servlet-name>Helloworldgae</servlet-name> <!-- class name --> <servlet-class>eurecom.fr.helloworldgae.HelloworldgaeServlet</servlet-class> <!-- class tree --> </servlet> <servlet-mapping> <servlet-name>Helloworldgae</servlet-name> <!-- class name --> <url-pattern>/helloworldgae</url-pattern> </servlet-mapping> <!-- Class pattern in the URL-->
25/12/2013 - - p 9
![Page 10: Lab session Google Application Engine - GAE](https://reader033.vdocuments.us/reader033/viewer/2022052805/628f4cad3c1e2448a9074315/html5/thumbnails/10.jpg)
Servlet
Java class that runs on the server side that receives HTTP data and does a processing or more following the contraints of the HTTP protocol
- p 10
@WebServlet("/Hello") public class Hello extends HttpServlet { // called at the reception of the http POST request protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); try { out.println("Hello World"); } finally { out.close(); } } // called at the reception of the http GET request protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/plain"); String msg = "Hello, world"; if (request.getParameter("name") != null) { msg += " from " + request.getParameter("name"); } response.getWriter().println(msg); }
![Page 11: Lab session Google Application Engine - GAE](https://reader033.vdocuments.us/reader033/viewer/2022052805/628f4cad3c1e2448a9074315/html5/thumbnails/11.jpg)
HTTP Response
Response type (see http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html ) 1XX: informative 2XX: success 3XX: redirection 4XX: client error 5XX: server error
Generate error protected void doXXX(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); try { response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE, "the server is overloaded. Please try later."); } finally { out.close(); } } See http://en.wikibooks.org/wiki/J2EE_Programming/Servlet
25/12/2013 - - p 11
![Page 12: Lab session Google Application Engine - GAE](https://reader033.vdocuments.us/reader033/viewer/2022052805/628f4cad3c1e2448a9074315/html5/thumbnails/12.jpg)
Java server pages - JSP
The JavaServer Pages is a technology for inserting dynamic content into a HTML or XML page using a Java servlet container Declaration: <%! int serverInstanceVariable = 1; %>
Scriptlet : <% int localStackBasedVariable = 1;
out.println(localStackBasedVariable); %>
Expression: <%= "expanded inline data " + 1 %>
Comment: <%-- This is my first JSP. --%>
Directive : <%@ page import="java.util.*" %>
25/12/2013 - - p 12
![Page 13: Lab session Google Application Engine - GAE](https://reader033.vdocuments.us/reader033/viewer/2022052805/628f4cad3c1e2448a9074315/html5/thumbnails/13.jpg)
Lab Session Steps
1. Helloworldgae [10 minutes]
2. Hellomoongae [40 minutes] 1. Create a servlet 2. JSP 3. Publish and deploy the code
3. AddressBook [1h30] 1. Database 2. POST and GET 3. List of contact and contact details 4. Modify contact 5. Output format in json
4. Website [10 minutes] 25/12/2013 - - p 13
![Page 14: Lab session Google Application Engine - GAE](https://reader033.vdocuments.us/reader033/viewer/2022052805/628f4cad3c1e2448a9074315/html5/thumbnails/14.jpg)
Technology
Google App Engine GAE PaaS cloud computing platform Developping and hosting web applications in google data center See https://developers.google.com/appengine/ and
http://en.wikipedia.org/wiki/Google_App_Engine
Appache Tomcat (formerly Jakarta Tomcat) open source web server and servlet container Implemnets java servlet and javaServer pages
25/12/2013 - - p 14
![Page 15: Lab session Google Application Engine - GAE](https://reader033.vdocuments.us/reader033/viewer/2022052805/628f4cad3c1e2448a9074315/html5/thumbnails/15.jpg)
EURECOM MEMBERS
25/12/2013 - - p 15