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 (Optional) Install Eclipse Java EE (to support jsp) 3

4 Install Google Plugin for Eclipse 4.5 Please follow the instruction at – https://developers.google.com/eclipse/docs/getti ng_started https://developers.google.com/eclipse/docs/getti ng_started – Remember the Java 1.7 note – Choose Google App Engine Java SDK Google Plugin for Eclipse 4.4/4.5 4

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

6 Fill in Wizard See left for recommended info – Unchecked Use GWT – Checked Use App id Click Browse … to choose an App id (see next slide if you do not have project ID) 6

7 Create App id See https://developers.google.com/eclipse/docs/getting _started#deploying on how to create an id I recommend that you pick an appid such as yalecs112- -, e.g., yalecs112-yry3- guestbook for me 7

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

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

10 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/ 10

11 If Everything Goes Well 11

12 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 12

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

14 Outline Getting started Guestbook example – Log in 14

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

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

17 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 17

18 18

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

20 20

21 Time to Test See Slide 12 21

22 Stop Server It is always a good idea to stop testing by clicking the red square – If you do not see it, click the console (typically a small icon on the right) and then you will see the red square 22

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

24 Add a Form to Allow Posting Insert before 24

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

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

27 27

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

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

30 Time to Test See Slide 12 30

31 Outline Getting started Guestbook example Todo example 31

32 32

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

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

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

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

37 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 37

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

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

40 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/ 40

41 If Everything Goes Well 41

42 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 42

43 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/ 43

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

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

46 Create EMFService 46

47 Create Two Servlets 47

48 Outline Getting started Guestbook example Todo example Simplified Madlib 48


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

Similar presentations


Ads by Google