網路科技

Google App Engine (1)

🏆 超過70萬名讀者已閱讀本站的內容,共同創造了105萬次總閱讀次數!

一般所謂的雲端服務分為 SaaS (Software as a Service),PaaS (Platform as a Service),和 IaaS (Infrastructure as a Service)。而本篇主角 Google App Engine 則是 PaaS 的代表之一。https://developers.google.com/appengine/training/intro/whatisgae

這兩天抽空將 GAE (Google App Engine) 的流程走了一遍,包含佈署 (deploy) 上線。https://developers.google.com/appengine/docs/java/gettingstarted/

專案資料夾主要分為 src 與 war。src 當然就是放你的原始碼,war 資料夾在最終會上傳佈署,其中包含:css、html、xml、jsp、多媒體資源檔、compiled byte-code,和相依的 jar libraries。

Eclipse “Web Application Project” 模版 “war” folder 裡 “index.html” 為網站的入口頁面。

“warWEB-INF” 裡的 “web.xml” 為 “web application deployment descriptor”。其宣告了 <servlet>,<servlet-mapping>,和 <welcome-file-list>。

<welcome-file-list> 的 default 值是 “index.html”。根據:
https://developers.google.com/appengine/docs/java/gettingstarted/creating

“It also says that, whenever the user fetches a URL path that is not already mapped to a servlet and represents a directory path inside the application's WAR, the server should check for a file named index.html in that directory and serve it if found.”

另外還有一 “appengine-web.xml”,則是 GAE 專屬,其 <application> 標籤是重點,須與你的 GAE application ID 同。指定 JSP 網頁的方式:
https://developers.google.com/appengine/docs/java/gettingstarted/usingjsps

開發過程主要就是新增 JSP 檔和在 “web.xml” 指定你 JSP 檔的 mapping URL。當然 JSP 檔可以跟 Java servlet 做互動。

GAE 提供了免費 (或是一定費用) 的虛擬 server,免去採購 server,設定 server,建置維護網站運行環境所需的人力與金錢。

附註:GAE 目前還不成熟,tool chain 的建置不是很順暢,很多東西要 google 一陣子才知道做法。

我是 Larry,經營 B2B 軟體公司超過 10 年,也持續寫作超過 15 年。
我會持續分享自己對商業、科技與生活的觀察。

如果你喜歡這篇文章,也歡迎追蹤我的社群:
📌 Threads|日常觀察與商業思考
📌 FB|文章與生活分享
📌 IG|旅行、美食短影片