Presentation is loading. Please wait.

Presentation is loading. Please wait.

Google App Engine using Java 1. Outline Getting started Guestbook example Todo example Simplified Madlib 2.

Similar presentations


Presentation on theme: "Google App Engine using Java 1. Outline Getting started Guestbook example Todo example Simplified Madlib 2."— Presentation transcript:

1 Google App Engine using Java 1

2 Outline Getting started Guestbook example Todo example Simplified Madlib 2

3 Install: Eclipse Java EE Install Eclipse Java EE (to support jsp) 3

4 Set Security, if needed If eclipse will not run because of Security, – System Preference – Security & Privacy – For “Eclipse” was blocked from opening, click “Open Anyway” 4

5 Install Google Plugin for Eclipse 4.3 Please follow the instruction at – https://developers.google.com/eclipse/docs/instal l-eclipse-4.3 https://developers.google.com/eclipse/docs/instal l-eclipse-4.3 5

6 Create First GAE App in Eclipse File -> New – For me, I looked under Other and then Google to find Web Application Project – Click Next 6

7 Fill in Wizard See left for recommended info – Unchecked Use Google Web Toolkit – Checked Use App id Click Browse … to choose an App id 7

8 Create App id You will need to log in to Google first. Click Create App Id I recommend that you pick an appid such as yalecs112- -, e.g., yalecs112-yry3- guestbook for me 8

9 Directory Structure – src edu.yale.cs112 – [Servlets go here] – war [JSPs go here] lib – appengine-web.xml – web.xml 9

10 Directory Structure Java/Servlet code will go under src Pretty much everything else will go under war – Static files HTML CSS – Configuration files 10

11 Test First (Local Run) Right click project Go to Debug as (or Run as) > Web application Check Console to see message: – INFO: Dev App Server is now running After a few seconds, navigate to http://localhost:8888/ 11

12 If Everything Goes Well 12

13 Test Real Deployment Click on the g icon and then Deploy to App Engine The deployment may take a few min. If bored, you can login in to – https://appengine. google.com/ https://appengine. google.com/ To take a look at the status 13

14 Buggy GAE Sometime it may take a long time and eclipse still shows deploying, but the instance might have already been deployed. Check the GAE console – Click on the app id, and look for versions, or try – http://yalecs112-yry3-guestbook.appspot.com/ 14

15 Outline Getting started Guestbook example – Log in 15

16 Create Guestbook jsp Click on war, right click, New -> Other, specify jsp as filter, Next, specify guestbook.jsp, choose New JSP file (HTML), Finish 16

17 Create guestbookdemo.jsp Content See guestbook.jsp (cut-paste from ppt note) Make sure that you have guestbook.jsp to be under war 17

18 Configure Mapping war/WEB-INF/web.xml configures the mapping of the Web site, e.g., the first page (welcome page) to visit Change the welcome page from index.html to guestbook.jsp 18

19 19

20 Create CSS guestbook.jsp uses guestbookstyle.css to control display. Hence, add guestbookstyle.css – Click war, right click, New, Folder with name stylesheets. – Right click on the stylesheets folder > New > Other – Search for CSS File > Next – File name: guestbookstyle.css 20

21 21

22 Time to Test See Slide 12 22

23 Stop Server It is always a good idea to stop testing by clicking the red square 23

24 Outline Getting started Guestbook example – Log in – Post to guestbook 24

25 Add a Form to Allow Posting Insert before 25

26 Create SignGuestbookServlet.java See SignGuestbookServlet.java (see ppt note) 26

27 Update Mapping Tells App Engine that if a URL is to /sign, it will invoke the SignGuestbookServlet – Update war/WEB-INF/web.xml 27 sign edu.yale.cs112.SignGuestbookServlet sign /sign

28 28

29 Outline Getting started Guestbook example – Log in – Post to guestbook – Display content 29

30 Add Display of Existing Msgs See guestbook.jsp Step 3 part 30

31 Time to Test See Slide 12 31

32 Outline Getting started Guestbook example Todo example 32

33 33

34 Todo Illustrates how to use Java Persistence API (JPA) to store data http://www.vogella.com/tutorials/GoogleApp EngineJava/article.html 34

35 JPA Basic Idea Each data item is represented as a Class 35

36 Create First GAE App in Eclipse File -> New – For me, I looked under Other and then Google to find Web Application Project – Click Next 36

37 Fill in Wizard See left for recommended info – Unchecked Use Google Web Toolkit – Check “Use App id” Click Browse … to choose an App id 37

38 Create App id You will need to log in to Google first. Click Create App Id I recommend that you pick an appid such as yalecs112- -todo, e.g., yalecs112-yry3- todo for me 38

39 Directory Structure – src edu.yale.cs112 – [Servlets go here] – war [JSPs go here] lib – appengine-web.xml – web.xml 39

40 Directory Structure Java/Servlet code will go under src Pretty much everything else will go under war – Static files HTML CSS – Configuration files 40

41 Test First (Local Run) Right click project Go to Debug as (or Run as) > Web application Check Console to see message: – INFO: Dev App Server is now running After a few seconds, navigate to http://localhost:8888/ 41

42 If Everything Goes Well 42

43 Test Real Deployment Click on the g icon and then Deploy to App Engine The deployment may take a few min. If bored, you can login in to – https://appengine. google.com/ https://appengine. google.com/ To take a look at the status 43

44 Buggy GAE? Sometime it may take a long time and eclipse still shows deploying, but the instance might have already been deployed. Check the GAE console – Click on the app id, and look for versions, or try – http://yalecs112-yry3-todo.appspot.com/ 44

45 Create Todo.java Model Click src, edu.yale.cs1 12, right click, new Class Todo, make package edu.yale.cs1 12.model 45

46 Check persistence.xml Check META-INF/persistence.xml 46

47 Create EMFService 47

48 Create Two Servlets 48

49 Outline Getting started Guestbook example Todo example Simplified Madlib 49


Download ppt "Google App Engine using Java 1. Outline Getting started Guestbook example Todo example Simplified Madlib 2."

Similar presentations


Ads by Google