- •Contents
- •Practice №1 The study of cloud services Google. Gmail.
- •1.1 About Gmail
- •1.2 Why choose Gmail
- •1.3 Creating an account
- •1.4 Gmail as a Google Account
- •2. Gmail’s Interface
- •2.1 Inbox
- •2.2 Compose Mail
- •2.3 Drafts
- •2.4 Sent Mail
- •2.5 More
- •2.6 Report Spam
- •2.7 Delete
- •2.8 Keyboard Shortcuts
- •3. Organizing your Gmail
- •3.1 Contacts
- •3.2 Stars
- •3.3 Labels
- •4. Advanced Settings
- •4.1 General Settings
- •4.2 Accounts and Import
- •4.3 Filters
- •4.4 Forwarding and Pop/imap
- •4.5 Offline
- •5. The Fun Stuff
- •5.1 Buzz
- •5.2 Chat
- •5.3 Web Clips
- •5.4 Labs
- •5.5 Themes
- •5.6 Gmail Mobile
- •5.7 Google Docs
- •5.8 Google Calendar
- •5.9 Tasks
- •6. Conclusion
- •Practice №2 The study of cloud services Google Talk.
- •2.1 Use the native Gmail Talk option
- •2.2 Installing the voice/video chat plugin
- •Practice №3 The study of cloud services Google Calendar
- •3.1 Interface
- •3.2 Create an event
- •3.3 Add location
- •3.4 Invite people
- •3.5 Share meeting materials
- •3.6 Meet online
- •Invite guests, add attachments, and meet online.
- •3.7 New committee? New (shared) calendar.
- •Practice №4 Editing of electronic documents Google Apps
- •4.1 Creating new files
- •4.2 Using templates
- •Practice №5 The study of functions Google App Engine
- •5.1 Google App Engine Docs
- •5.2 Download the App Engine sdk for php
- •5.3 Creating the Configuration File
- •Practice №6 Creating a data warehouse environment Google App Engine
- •6.1 Setting up Objectify
- •6.2 Creating the data model classes
- •6.3 Adding the greetings and the form to the jsp template
- •6.4 Creating the form handling servlet
- •6.5 Testing the app
- •6.6 Creating required indexes
- •Practice №7 The study of cloud services Google Apps
- •7.1 Gmail
- •Google Drive
- •Google Docs, Sheets, Slides, and Forms
- •7.4 Google Sites
- •7.5 Google Calendar
- •7.6 Google Hangouts
- •7.8 Google Apps Vault
- •7.9 Usage
- •Practice №8 Microsoft Office Live Workspace
- •8.1 Setting up Microsoft Live Workspace
- •8.2 Features Available with Office Live Workspace
- •Practice №9 The study of cloud services Microsoft SkyDrive
- •9.1 Creating a Microsoft account
- •9.2 Getting to know OneDrive
- •9.3 Installing the Microsoft OneDrive app
- •9.4 OneDrive for mobile devices
- •Practice №10 Network services for the mobile user. Wi-Fi technology
- •10.1 What is Wi-Fi ?
- •Practice №11 Search engines in Internet
- •Veronica & Jughead:
- •Improve Your Searching Skills:
- •Infoseek:
- •Inktomi:
- •Vertical Search
- •Verticals Galore!
- •Information Retrieval as a Game of Mind Control
- •Increasing The Rate of Algorithmic Change
- •Practice №12 Search graphic information in Internet. Comparative analysis of search engines. Internet image search
- •Study Guide
- •3 55029, Stavropol, Pushkina, 1
6.3 Adding the greetings and the form to the jsp template
In guestbook/src/main/webapp, edit guestbook.jsp. Add the following lines to the imports at the top:
<%@ page import="com.example.guestbook.Greeting" %> <%@ page import="com.example.guestbook.Guestbook" %> <%@ page import="com.googlecode.objectify.Key" %> <%@ page import="com.googlecode.objectify.ObjectifyService" %>
Just above the line <form action="/guestbook.jsp" method="get">, add the following code:
<% // Create the correct Ancestor key Key<Guestbook> theBook = Key.create(Guestbook.class, guestbookName); // Run an ancestor query to ensure we see the most up-to-date // view of the Greetings belonging to the selected Guestbook. List<Greeting> greetings = ObjectifyService.ofy() .load() .type(Greeting.class) // We want only Greetings .ancestor(theBook) // Anyone in this book .order("-date") // Most recent first - date is indexed. .limit(5) // Only show 5 of them. .list(); if (greetings.isEmpty()) { %> <p>Guestbook '${fn:escapeXml(guestbookName)}' has no messages.</p> <% } else { %> <p>Messages in Guestbook '${fn:escapeXml(guestbookName)}'.</p> <% // Look at all of our greetings for (Greeting greeting : greetings) { pageContext.setAttribute("greeting_content", greeting.content); String author; if (greeting.author_email == null) { author = "An anonymous person"; } else { author = greeting.author_email; String author_id = greeting.author_id; if (user != null && user.getUserId().equals(author_id)) { author += " (You)"; } } pageContext.setAttribute("greeting_user", author); %> <p><b>${fn:escapeXml(greeting_user)}</b> wrote:</p> <blockquote>${fn:escapeXml(greeting_content)}</blockquote> <% } } %> <form action="/sign" method="post"> <div><textarea name="content" rows="3" cols="60"></textarea></div> <div><input type="submit" value="Post Greeting"/></div> <input type="hidden" name="guestbookName" value="${fn:escapeXml(guestbookName)}"/> </form>
When the user loads the page, the template performs a datastore query for all Greeting entities that use the same Guestbook in their key. The query is sorted by date in reverse chronological order ("-date"), and results are limited to the five most recent greetings. The rest of the template displays the results as HTML, and also renders the form that the user can use to post a new greeting.
6.4 Creating the form handling servlet
The web form sends an HTTP POST request to the /sign URL. Let's create a servlet to handle these requests.
In guestbook/src/main/java/com/example/guestbook, create a file named SignGuestbookServlet.java, and give it the following contents:
package com.example.guestbook; import com.google.appengine.api.datastore.DatastoreService; import com.google.appengine.api.datastore.DatastoreServiceFactory; import com.google.appengine.api.datastore.Entity; import com.google.appengine.api.datastore.Key; import com.google.appengine.api.datastore.KeyFactory; import com.google.appengine.api.users.User; import com.google.appengine.api.users.UserService; import com.google.appengine.api.users.UserServiceFactory; import java.io.IOException; import java.util.Date; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.googlecode.objectify.ObjectifyService; /** * Form Handling Servlet * Most of the action for this sample is in webapp/guestbook.jsp, which displays the * {@link Greeting}'s. This servlet has one method * {@link #doPost(<#HttpServletRequest req#>, <#HttpServletResponse resp#>)} which takes the form * data and saves it. */ public class SignGuestbookServlet extends HttpServlet { // Process the http POST of the form @Override public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException { Greeting greeting; UserService userService = UserServiceFactory.getUserService(); User user = userService.getCurrentUser(); // Find out who the user is. String guestbookName = req.getParameter("guestbookName"); String content = req.getParameter("content"); if (user != null) { greeting = new Greeting(guestbookName, content, user.getUserId(), user.getEmail()); } else { greeting = new Greeting(guestbookName, content); } // Use Objectify to save the greeting and now() is used to make the call synchronously as we // will immediately get a new page using redirect and we want the data to be present. ObjectifyService.ofy().save().entity(greeting).now(); resp.sendRedirect("/guestbook.jsp?guestbookName=" + guestbookName); } }
This servlet is the POST handler for the greetings posted by users. It takes the the greeting (content) from the incoming request and stores it in Datastore as a Greeting entity. Its properties include the content of the post, the date the post was created, and, if the user is signed in, the author's ID and email address. For more information about entities in App Engine, see Entities, Properties, and Keys.
Finally, in guestbook/src/main/webapp/WEB-INF/, edit web.xml and ensure the new servlets have URLs mapped. The final version should look like this:
<?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <servlet> <servlet-name>sign</servlet-name> <servlet-class>com.example.guestbook.SignGuestbookServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>sign</servlet-name> <url-pattern>/sign</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>guestbook.jsp</welcome-file> </welcome-file-list> <filter> <filter-name>ObjectifyFilter</filter-name> <filter-class>com.googlecode.objectify.ObjectifyFilter</filter-class> </filter> <filter-mapping> <filter-name>ObjectifyFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <listener> <listener-class>com.example.guestbook.OfyHelper</listener-class> </listener> </web-app>
