Weitere ähnliche Inhalte Ähnlich wie ネットワーク第2回目 (20) ネットワーク第2回目7. PaaS(Platform as a Service)
ソフトウウェアを構築させる土
台となるプラットフォームを、
インターネット経由で使用する
ことが出来るサービス
Herokuの場合、ベースとなるOS
は、DebianもしくはDebianを
ベースに開発されたUbuntu
24. src/main/webapps/index.jsp に以下を追
加する
<a href=“hello?method=get”>GETリクエス
ト</a><br>
<form action=“hello” method=“post”>
POSTリクエストをする
<input type=“text”>
<input type=“submit”
name=“submit” value=“送信”>
</form>
25. HelloServlet.javaを変更する
doGetメソッド内に以下のように修正
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
ServletOutputStream out = resp.getOutputStream();
StringBuffer sb = new StringBuffer();
sb.append("---------- request Line ----------------n");
sb.append("method : ").append(req.getMethod()).append("n");
sb.append("requestURL : ").append(req.getRequestURI()).append("n");
sb.append("get query : ").append(req.getQueryString()).append("n");
Enumeration params = req.getParameterNames();
while(params.hasMoreElements()){
String param = (String) params.nextElement();
sb.append(param).append(" :
").append(req.getParameter(param)).append("n");
}
sb.append("n");
26. sb.append("---------- request Headers ----------------n");
Enumeration headerNames = req.getHeaderNames();
while(headerNames.hasMoreElements()) {
String headerName = (String) headerNames.nextElement();
sb.append(headerName).append(" :
").append(req.getHeader(headerName)).append("n");
}
out.write(sb.toString().getBytes());
out.flush();
out.close();
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
this.doGet(req, resp);
}
28. GET /index.html HTTP/1.1
Host : localhost:8080
Accept : text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Language : ja,en-US;q=0.8,en;q=0.6
Referer : http://localhost:8080/
User-Agent : Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/30.0.1599.66 Safari/537.36
Connection : keep-alive
Accept-Encoding : gzip, deflate
aaa=bbb&ccc=dddd
空行(CRLF)
31. 番号 意味
200 OK(成功)
302 Found (リダイレクト)
304 Not Modified (キャッシュを参照)
400 Bad Request (Clientからのリクエスト不備)
403 Forbidden (アクセス禁止)
404 Not Found (ページが存在しない)
500 Internal Server Error (サーバエラー)
503 Service Unavailable (サーバが過負荷状態)
32. Heroku Eclipse Pluginの設定
https://devcenter.heroku.com/articles/getting-started-with-heroku-eclipse
TCP/IP HTTPとは
http://www.infraexpert.com/study/tcpip16.html