- 浏览: 2566678 次
- 性别:
- 来自: 成都
-
文章分类
最新评论
-
nation:
你好,在部署Mesos+Spark的运行环境时,出现一个现象, ...
Spark(4)Deal with Mesos -
sillycat:
AMAZON Relatedhttps://www.godad ...
AMAZON API Gateway(2)Client Side SSL with NGINX -
sillycat:
sudo usermod -aG docker ec2-use ...
Docker and VirtualBox(1)Set up Shared Disk for Virtual Box -
sillycat:
Every Half an Hour30 * * * * /u ...
Build Home NAS(3)Data Redundancy -
sillycat:
3 List the Cron Job I Have>c ...
Build Home NAS(3)Data Redundancy
Google App Engine(4)Java Start and Datastore
One Tip: sometimes, if you want to kill a app engine development server, just use this command to grep the information.
>ps -ef | grep appengine
A scalable web application will face a user interacting with any of dozens of web servers at a given time, and the user's next request could go to a different web server than the previous request.
App Engine includes support for 2 different API standards for the Datastore: Java Data Objects(JDO) and the Java Persistence API(JPA).
Updating the Servlet to Store Data
String guestbookName = req.getParameter("guestbookName");
Key guestbookKey = KeyFactory.createKey("Guestbook", guestbookName); // database
log.info("Greeting posted by user " + user.getNickname() + ": "
+ guestbookName);
String content = req.getParameter("content");
Date date = new Date();
Entity greeting = new Entity("Greeting", guestbookKey); //table
greeting.setProperty("user", user);
greeting.setProperty("date", date);
greeting.setProperty("content", content);
DatastoreService datastore = DatastoreServiceFactory
.getDatastoreService();
datastore.put(greeting);
resp.sendRedirect("/guestbook.jsp?guestbookName=" + guestbookName);
Storing the Submitted Greetings
…snip…
Updating the JSP
<%
String guestbookName = request.getParameter("guestbookName");
if (guestbookName == null) {
guestbookName = "default";
}
pageContext.setAttribute("guestbookName", guestbookName);
UserService userService = UserServiceFactory.getUserService();
User user = userService.getCurrentUser();
if (user != null) {
pageContext.setAttribute("user", user);
%>
<p>
Hello, ${fn:escapeXml(user.nickname)}! (You can <a
href="<%=userService.createLogoutURL(request.getRequestURI())%>">sign
out</a>.)
</p>
<%
} else {
%>
<p>
Hello! <a
href="<%=userService.createLoginURL(request.getRequestURI())%>">Sign
in</a> to include your name with greetings you post.
</p>
<%
}
%>
<%
DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
Key guestbookKey = KeyFactory.createKey("Guestbook", guestbookName); //database
Query query = new Query("Greeting", guestbookKey).addSort("date",
Query.SortDirection.DESCENDING); //table
List<Entity> greetings = datastore.prepare(query).asList(
FetchOptions.Builder.withLimit(5));
if (greetings.isEmpty()) {
%>
<p>Guestbook '${fn:escapeXml(guestbookName)}' has no messages.</p>
<%
} else {
%>
<p>Messages in Guestbook '${fn:escapeXml(guestbookName)}'.</p>
<%
for (Entity greeting : greetings) {
pageContext.setAttribute("greeting_content", greeting.getProperty("content"));
if (greeting.getProperty("user") == null) {
%>
<p>An anonymous person wrote:</p>
<%
} else {
pageContext.setAttribute("greeting_user",
greeting.getProperty("user"));
%>
<p>
<b>${fn:escapeXml(greeting_user.nickname)}</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>
Retrieving the Stored Greetings
Read this in detail
https://developers.google.com/appengine/docs/java/datastore/
A Word About Datastore Indexes
https://developers.google.com/appengine/docs/java/datastore/indexes
Clearing the Datastore
delete the file WEB-INF/appengine-generated/local_db.bin
Use Static Files
By default, App Engine makes all files in the WAR available as static files except JSPs and files in WEB-INF/,
A Simple Stylesheet
create a directory named stylesheets/ under war/. File main.css.
body {
font-family: Verdana,Helvetica,sans-serif;
background-color: #FFFFCC;
}
Directly use that URL in JSP files:
<head>
<link type="text/css"rel="stylesheet"href="/stylesheets/main.css"/>
</head>
Uploading Your Application
Create Application from here: https://appengine.google.com/
Uploading From Eclipse
click 'Deploy to App Engine', and I already enter my google account and choose the project 4mymessage.
And I place the application Id in the configuration file
Verify the front page from URL http://4mymessage.appspot.com
When I have time, I will go on the sample in this URL http://googcloudlabs.appspot.com/.
References:
https://developers.google.com/appengine/docs/java/gettingstarted/usingdatastore
https://developers.google.com/appengine/docs/java/gettingstarted/staticfiles
https://developers.google.com/appengine/docs/java/gettingstarted/uploading
http://googcloudlabs.appspot.com/
One Tip: sometimes, if you want to kill a app engine development server, just use this command to grep the information.
>ps -ef | grep appengine
A scalable web application will face a user interacting with any of dozens of web servers at a given time, and the user's next request could go to a different web server than the previous request.
App Engine includes support for 2 different API standards for the Datastore: Java Data Objects(JDO) and the Java Persistence API(JPA).
Updating the Servlet to Store Data
String guestbookName = req.getParameter("guestbookName");
Key guestbookKey = KeyFactory.createKey("Guestbook", guestbookName); // database
log.info("Greeting posted by user " + user.getNickname() + ": "
+ guestbookName);
String content = req.getParameter("content");
Date date = new Date();
Entity greeting = new Entity("Greeting", guestbookKey); //table
greeting.setProperty("user", user);
greeting.setProperty("date", date);
greeting.setProperty("content", content);
DatastoreService datastore = DatastoreServiceFactory
.getDatastoreService();
datastore.put(greeting);
resp.sendRedirect("/guestbook.jsp?guestbookName=" + guestbookName);
Storing the Submitted Greetings
…snip…
Updating the JSP
<%
String guestbookName = request.getParameter("guestbookName");
if (guestbookName == null) {
guestbookName = "default";
}
pageContext.setAttribute("guestbookName", guestbookName);
UserService userService = UserServiceFactory.getUserService();
User user = userService.getCurrentUser();
if (user != null) {
pageContext.setAttribute("user", user);
%>
<p>
Hello, ${fn:escapeXml(user.nickname)}! (You can <a
href="<%=userService.createLogoutURL(request.getRequestURI())%>">sign
out</a>.)
</p>
<%
} else {
%>
<p>
Hello! <a
href="<%=userService.createLoginURL(request.getRequestURI())%>">Sign
in</a> to include your name with greetings you post.
</p>
<%
}
%>
<%
DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
Key guestbookKey = KeyFactory.createKey("Guestbook", guestbookName); //database
Query query = new Query("Greeting", guestbookKey).addSort("date",
Query.SortDirection.DESCENDING); //table
List<Entity> greetings = datastore.prepare(query).asList(
FetchOptions.Builder.withLimit(5));
if (greetings.isEmpty()) {
%>
<p>Guestbook '${fn:escapeXml(guestbookName)}' has no messages.</p>
<%
} else {
%>
<p>Messages in Guestbook '${fn:escapeXml(guestbookName)}'.</p>
<%
for (Entity greeting : greetings) {
pageContext.setAttribute("greeting_content", greeting.getProperty("content"));
if (greeting.getProperty("user") == null) {
%>
<p>An anonymous person wrote:</p>
<%
} else {
pageContext.setAttribute("greeting_user",
greeting.getProperty("user"));
%>
<p>
<b>${fn:escapeXml(greeting_user.nickname)}</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>
Retrieving the Stored Greetings
Read this in detail
https://developers.google.com/appengine/docs/java/datastore/
A Word About Datastore Indexes
https://developers.google.com/appengine/docs/java/datastore/indexes
Clearing the Datastore
delete the file WEB-INF/appengine-generated/local_db.bin
Use Static Files
By default, App Engine makes all files in the WAR available as static files except JSPs and files in WEB-INF/,
A Simple Stylesheet
create a directory named stylesheets/ under war/. File main.css.
body {
font-family: Verdana,Helvetica,sans-serif;
background-color: #FFFFCC;
}
Directly use that URL in JSP files:
<head>
<link type="text/css"rel="stylesheet"href="/stylesheets/main.css"/>
</head>
Uploading Your Application
Create Application from here: https://appengine.google.com/
Uploading From Eclipse
click 'Deploy to App Engine', and I already enter my google account and choose the project 4mymessage.
And I place the application Id in the configuration file
Verify the front page from URL http://4mymessage.appspot.com
When I have time, I will go on the sample in this URL http://googcloudlabs.appspot.com/.
References:
https://developers.google.com/appengine/docs/java/gettingstarted/usingdatastore
https://developers.google.com/appengine/docs/java/gettingstarted/staticfiles
https://developers.google.com/appengine/docs/java/gettingstarted/uploading
http://googcloudlabs.appspot.com/
发表评论
-
Stop Update Here
2020-04-28 09:00 331I will stop update here, and mo ... -
NodeJS12 and Zlib
2020-04-01 07:44 491NodeJS12 and Zlib It works as ... -
Docker Swarm 2020(2)Docker Swarm and Portainer
2020-03-31 23:18 377Docker Swarm 2020(2)Docker Swar ... -
Docker Swarm 2020(1)Simply Install and Use Swarm
2020-03-31 07:58 381Docker Swarm 2020(1)Simply Inst ... -
Traefik 2020(1)Introduction and Installation
2020-03-29 13:52 351Traefik 2020(1)Introduction and ... -
Portainer 2020(4)Deploy Nginx and Others
2020-03-20 12:06 439Portainer 2020(4)Deploy Nginx a ... -
Private Registry 2020(1)No auth in registry Nginx AUTH for UI
2020-03-18 00:56 449Private Registry 2020(1)No auth ... -
Docker Compose 2020(1)Installation and Basic
2020-03-15 08:10 392Docker Compose 2020(1)Installat ... -
VPN Server 2020(2)Docker on CentOS in Ubuntu
2020-03-02 08:04 475VPN Server 2020(2)Docker on Cen ... -
Buffer in NodeJS 12 and NodeJS 8
2020-02-25 06:43 401Buffer in NodeJS 12 and NodeJS ... -
NodeJS ENV Similar to JENV and PyENV
2020-02-25 05:14 496NodeJS ENV Similar to JENV and ... -
Prometheus HA 2020(3)AlertManager Cluster
2020-02-24 01:47 438Prometheus HA 2020(3)AlertManag ... -
Serverless with NodeJS and TencentCloud 2020(5)CRON and Settings
2020-02-24 01:46 346Serverless with NodeJS and Tenc ... -
GraphQL 2019(3)Connect to MySQL
2020-02-24 01:48 262GraphQL 2019(3)Connect to MySQL ... -
GraphQL 2019(2)GraphQL and Deploy to Tencent Cloud
2020-02-24 01:48 463GraphQL 2019(2)GraphQL and Depl ... -
GraphQL 2019(1)Apollo Basic
2020-02-19 01:36 336GraphQL 2019(1)Apollo Basic Cl ... -
Serverless with NodeJS and TencentCloud 2020(4)Multiple Handlers and Running wit
2020-02-19 01:19 322Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(3)Build Tree and Traverse Tree
2020-02-19 01:19 330Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(2)Trigger SCF in SCF
2020-02-19 01:18 306Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(1)Running with Component
2020-02-19 01:17 320Serverless with NodeJS and Tenc ...
相关推荐
标题中的"appengine-java-sdk-1.3.1"指的是Google App Engine的Java版本SDK,这是一个用于在Google云平台上开发和部署Java应用程序的工具包。这个SDK包含了运行和测试Google App Engine应用所需的所有组件,包括开发...
**谷歌AppEngine与Java SDK详解** 谷歌AppEngine(Google App Engine)是一款强大的云计算平台,它允许开发者使用Java、Python、Go或PHP等语言构建并运行Web应用。AppEngine提供了全面的后端服务,包括数据库存储、...
Java版本的App Engine,即我们讨论的"appengine-java-sdk-1.8.7.zip",是Google专门为Java开发者提供的工具包,用于在GAE上开发应用。 **主要组件和功能** 1. **SDK(Software Development Kit)**: SDK包含了开发...
标题中的"appengine-java-sdk-1.5.0.1.zip"表明这是一个关于Google App Engine Java SDK的压缩包,版本号为1.5.0.1。App Engine是由Google提供的一个平台,允许开发者使用Java或Python等语言创建并运行web应用程序。...
Beginning Java Google App Engine - Kyle Roche and Jeff Douglas.pdf Google App Engine is one of the key technologies to emerge in recent years to help you build scalable web applications even if you ...
4. 访问控制和安全机制:Google App Engine提供了内置的安全机制,如身份验证、授权以及防火墙等,以保证应用和数据的安全。 5. 分发和负载均衡:在多个服务器之间分发用户请求是GAE自动处理的,它还可以根据流量的...
### 编程Google App Engine使用Java - 关键知识点解析 #### 一、书籍概述与背景 《Programming Google App Engine with Java》是一本详细介绍如何利用Google App Engine (GAE) 构建可扩展Java应用程序的专业书籍。...
标题中的“初用Google App Engine for Java”表明我们要探讨的是如何使用Google的App Engine平台来开发Java应用程序。Google App Engine是一个基于云计算的平台,它允许开发者构建和运行Web应用程序,无需管理和维护...
1. **安装SDK**:下载并安装appengine-java-sdk-1.3.0_d9soft-part1压缩包,解压后配置环境变量,确保开发工具能够找到SDK路径。 2. **创建项目**:使用SDK提供的命令行工具或集成开发环境(IDE,如Eclipse或...
在“google-appengine-docs-20081003”这个压缩包中,可能包含了早期版本(2008年10月3日)的Google App Engine开发指南、API参考、最佳实践和示例代码等内容。这些文档帮助开发者了解如何利用Google App Engine构建...
原名: Google App Engine Java and GWT Application Development 作者: Daniel Guermeur, Amy Unruh 资源格式: PDF 版本: 文字版 出版社: Packt Publishing书号: 1849690448发行时间: 2010年 地区: 美国 语言: 英文 ...
标题 "Packt.Google.App.Engine.Java.and.GWT.Application.Development.Source.Code" 暗示了这是一个关于使用Java和GWT在Google App Engine上开发应用程序的源代码包。这为我们提供了几个关键知识点: 1. **Google ...
### Apress - Beginning Java Google App Engine(Java)(Dec 2009) 关键知识点解析 #### 一、概述 本书由 Kyle Roche 和 Jeff Douglas 合著,旨在为使用 Java 技术的 Web 开发者提供关于 Google App Engine 的核心...
《Google App Engine Java和GWT应用开发》一书聚焦于如何利用Google App Engine(GAE)平台、Java语言以及Google Web Toolkit(GWT)来构建强大、可扩展且交互式的云端Web应用程序。这本书由Daniel Guermeur和Amy ...
本示例主要关注如何将文件上传到Google App Engine的数据存储(Datastore)。数据存储是GAE的一个核心组件,它是一个NoSQL的键值对数据库,用于存储应用程序的数据。 在"上传文件到Google app engine datastore的...
3. **项目结构**:解释一个典型的GAE Java项目的目录结构,包括`war`目录、`src`目录、`appengine-web.xml`和`web.xml`等关键文件的作用。 4. **开发第一个应用**:展示如何创建一个简单的Guestbook应用,这可能...
**Google App Engine**是Google提供的一种云计算平台,用于构建和托管Web应用程序。它允许开发者使用Python、Java、Go或PHP等语言编写应用,并在Google的基础设施上运行,无需关心服务器维护、扩展性和高可用性等...