1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Java Servlet

Posted at

はじめに

JavaServletについて自分用のメモ

JavaServletとは

動的なwebページの処理を行うための仕様。言語はJava

webページには動的と静的なwebページがある。

  • 静的なwebページ
  • いつ閲覧しても表示される内容が変わらない
  • 動的なwebページ
  • 表示した時間帯などによって表示内容が変わる

Servlet自体はWebブラウザからの要求に応えたり、送られてきたデータを処理したりするためのもので、単体ではWebアプリを作るための機能が少ない。
なので、tomcatやJSPと連携をしてアプリを作成することが多い。

javaで書かれているのでプラットフォームに依存しないのが特徴。

tomcatやJSPとはなにか

では、Servletと連携するtomcatやJSPは一体何者だ・・・。

tomcatとは

Servletや後述するJSPの実行環境となるソフトウェア。サーブレットコンテナとも言われる。

個人的にこのサイトの説明が参考になった。
Apacheとtomcat

JSP(JavaServerpage)とは

基本はHTMLで動的な処理を書く場合にJava処理を記述できるファイル
拡張子(.jsp)
Javaで処理を書く場合は<% %>で処理を囲む。

qiita.jsp
<%-- コメント --%>
<%@ page contentType="text/html;charset=Shift_JIS" %>
<html>
<head>
 <meta charset="UTF-8">
 <title>sampleJSP</title>
</head>
<body>
 <%
  String str = "Hello World";
  System.out.println(str);
 %>
</body>

*)この場合コンソールに処理結果がでます。記述の参考までに。

参考文献

技術評論社
teratail

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?