質問編集履歴
1
web.xmlとjavaのコードを追記致しました
title
CHANGED
File without changes
|
body
CHANGED
@@ -9,4 +9,80 @@
|
|
9
9
|
|
10
10
|
8080以外のポート番号を使うとダメなのでしょうか?
|
11
11
|
でも8080だとEclipse上でTomcatを起動できません。
|
12
|
-
どうすればよいのやら。。。どなたかお助けください!!!
|
12
|
+
どうすればよいのやら。。。どなたかお助けください!!!
|
13
|
+
|
14
|
+
【追記】
|
15
|
+
★web.xml
|
16
|
+
```
|
17
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
18
|
+
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
|
19
|
+
<servlet>
|
20
|
+
<servlet-name>SelfIntroduction</servlet-name>
|
21
|
+
<servlet-class>work.SelfIntroduction</servlet-class>
|
22
|
+
</servlet>
|
23
|
+
<servlet-mapping>
|
24
|
+
<servlet-name>SelfIntroduction</servlet-name>
|
25
|
+
<url-pattern>/SelfIntroduction</url-pattern>
|
26
|
+
</servlet-mapping>
|
27
|
+
</web-app>
|
28
|
+
```
|
29
|
+
|
30
|
+
★Javaコード
|
31
|
+
```Java
|
32
|
+
package work;
|
33
|
+
|
34
|
+
import java.io.IOException;
|
35
|
+
import java.io.PrintWriter;
|
36
|
+
|
37
|
+
import javax.servlet.ServletException;
|
38
|
+
import javax.servlet.http.HttpServlet;
|
39
|
+
import javax.servlet.http.HttpServletRequest;
|
40
|
+
import javax.servlet.http.HttpServletResponse;
|
41
|
+
|
42
|
+
public class SelfIntroduction extends HttpServlet {
|
43
|
+
|
44
|
+
private static final long serialVersionUID = 1L;
|
45
|
+
|
46
|
+
public SelfIntroduction() {
|
47
|
+
super();
|
48
|
+
}
|
49
|
+
|
50
|
+
protected void doGet(HttpServletRequest request, HttpServletResponse response)
|
51
|
+
throws ServletException, IOException {
|
52
|
+
|
53
|
+
//レスポンス(出力データ)の文字コードを設定
|
54
|
+
response.setContentType("text/html;charset=UTF-8"); //文字コードをUTF-8で設定
|
55
|
+
|
56
|
+
//出力用のストリームの取得
|
57
|
+
PrintWriter out = response.getWriter();
|
58
|
+
|
59
|
+
//HTML文書の出力
|
60
|
+
out.println( "<html> " );
|
61
|
+
out.println( "<head> " );
|
62
|
+
out.println( " <title>自己紹介</title> " );
|
63
|
+
out.println( "</head> " );
|
64
|
+
out.println( "<body> " );
|
65
|
+
out.println( " <h1>自己紹介ページ</h1> " );
|
66
|
+
out.println( " <h2>MOCO</h2> " );
|
67
|
+
out.println( " <img src=\"pictures/picture01_500x350.jpg\" width=\"250\" height=\"175\"> " );
|
68
|
+
out.println( " <hr width = \"400\" align = \"left\"> " );
|
69
|
+
out.println( " <p>・誕生 :2013年</p> " );
|
70
|
+
out.println( " <p>・出身 :台湾</p> " );
|
71
|
+
out.println( " <p>・職業 :就活犬(接客、メンタルケア)</p> " );
|
72
|
+
out.println( " <p>・好きな数字:「1(ONE)」</p> " );
|
73
|
+
out.println( " <p>・家族 :岡本</p> " );
|
74
|
+
out.println( " <img src=\"pictures/picture02_300x200.jpg\" width=\"150\" height=\"100\"> " );
|
75
|
+
out.println( "</body> " );
|
76
|
+
out.println( "</html> " );
|
77
|
+
|
78
|
+
}
|
79
|
+
|
80
|
+
protected void doPost(HttpServletRequest request, HttpServletResponse response)
|
81
|
+
throws ServletException, IOException {
|
82
|
+
|
83
|
+
doGet(request, response);
|
84
|
+
|
85
|
+
}
|
86
|
+
|
87
|
+
}
|
88
|
+
```
|