Servlet??(2) ???????????Web??? - PowerPoint PPT Presentation

About This Presentation
Title:

Servlet??(2) ???????????Web???

Description:

Title: Servlet (2) Web Author: Ryuhei Konno Last modified by: Ryuhei Konno Created Date: 5/23/2003 2:46:48 AM – PowerPoint PPT presentation

Number of Views:87
Avg rating:3.0/5.0
Slides: 42
Provided by: Ryuh
Category:
Tags: java | servlet | web

less

Transcript and Presenter's Notes

Title: Servlet??(2) ???????????Web???


1
Servlet??(2) ???????????Web???
  • ????? ????
  • s00395rk_at_sfc.keio.ac.jp

2
???????
  • Web???????????
  • ???????????????????
  • ??????????????
  • ??????????????????????????????????
  • Web???????????????()v

3
???????(1)
  • Web???????????
  • HTTP???????????????????????
  • ???????????????????
  • ??????????????
  • Web???????????????()v

4
???????(2)
  • Web???????????
  • ???????????????????
  • Web????Web??????????????????
  • ??????????????????
  • ??????????????
  • Web???????????????()v

5
???????(3)
  • Web???????????
  • ???????????????????
  • ??????????????
  • ?????????Java??????
  • HTTP???????????????????HTTP???????????
  • Web???????????????()v

6
???????(4)
  • Web???????????
  • ???????????????????
  • ??????????????
  • Web???????????????()v
  • Web?????????????
  • Web?????????????
  • ???Servlet????????????
  • Web????????????!!!!

7
?????
  • ??????????????????????????????????????????????
  • HTML?????????Servlet???????????????????????????Web
    ???????

8
Servlet?????????(1)??????????
Web Browser
Tomcat
???
TimeServlet.class
9
Servlet?????????(2)???????????
Web Application Server (Tomcat)
Web Browser
Web Server
Servlet Engine
TimeServlet.class
10
Servlet?????????(3)
  1. ?????Web????????HTTP???????????
  2. Web??????????????????????????????????
  3. ?????????????????????????????????????????????????
  4. ??????????????????????????????????????????????????
    ???Web???????
  5. Web?????????????????????????

11
Web?????????
  • Q.Web???????????????????

A.???????????????????
??????????????!
12
???Web????????
  • ???Web????
  • ?????????????????
  • ?????????????????????????
  • ??????Web????
  • ???????????????????????????????????????????
  • ???????????

13
?????????Web????
14
?????-??????Web???
Web????? ??????
index.html
15
??????-??????Web???
???
???
????
web.xml???????????
??
web.xml?????????????????????????????????????????
????????!
16
?????Servlet?????????
ApplicationServer
WebBrowser
toukou.html
???
ToukouServlet.class
17
HTTP GET?HTTP POST
  • ??????GET?POST????????????????????

18
????????
19
??????????????
ApplicationServer
WebBrowser
toukou.html
???
20
??????????HTML????
..ltform name"form1" method"post
action"../servlet/ToukouServlet"gt ltfont
size1gt???lt/fontgt ltinput type"text"
size"20" name"contributor"gt ltfont
size"1"gt????lt/fontgt ltinput type"text"
size"50" name"title" gt ltfont size"1"gt??lt/font
gt lttextarea namecontent" cols"50"
rows"10"gt lt/textareagt ltinput typesubmit
namesubmit value??gt ltinput typereset
namereset value????gt lt/formgt..
21
HTML???????(1)?????????
  • ltform nameform1 methodpost
  • action../servlet/ToukouServletgt

???????????????????(??)? ??????????????????(??)?
lt/formgt
22
HTML???????(2)???????????????
ltinput type " text " size " 20 " name "
contributor " gt
lttextarea name " content " cols"50"
rows"10"gtlt/textareagt
23
HTML???????(3)???????????????
ltinput type " submit " name " submit " value
"??" gt
ltinput type " reset " name " reset " value
"????" gt
24
???????
  • HTTP POST??????????

HTTP GET??????????????????????? GET
./servlet/ToukouServlet?contributor???titleweb.
xml HTTP/1.1 ??????????URL????????????? ????HTTP
POST??????????
25
???????? ??
?????
26
????????
27
??????????????
ApplicationServer
WebBrowser
???
ToukouServlet.class
28
???????????
POST ./servlet/ToukouServlet HTTP/1.1 Length 64
contributor???titleweb.xml????? question
web.xml?????????????
??? ???????????(Tomcat)? ???????????????????
29
??????????
  • ?????(Key)????(Value)????????????
  • ????????
  • ????????????name?Key
  • ??????????????Value

contributor ??? title
web.xml????? name web.xml?????????
30
??????2????
ToukouServlet.java
?????? ??????
????????????? (????????)
HTML????? ??
?????
31
public class ToukouServlet extends HttpServlet
/ doPost() ??????POST???????????
?????????????????????????? / public void
doPost(HttpServletRequest request,
HttpServletResponse response) throws
IOException, ServletException
//??????????????????? /
HTML????????????????????
??????????????????????????? /
request.setCharacterEncoding("Shift_JIS")
/ ???????????????????????????
???????????????????????? / String
contributor request.getParameter("contributor")
//??contributor?????????????contributor????
String title request.getParameter("title")
//??title?????????????title???? String
content request.getParameter("content")
//??content?????????????content????
//????????????????
//???????????????????
//??????????????????????????????
response.setContentType("text/htmlcharsetShift_J
IS") //??????????PrintWriter??????
PrintWriter out response.getWriter()
//HTML?????????????????/
out.println("lthtmlgt") out.println("ltbody
bgcolor\"33CCFF\" text\"000000\"gt")
out.println("lthrgt") //???????????????
out.print("ltbgtltfont size4gtltpgt"contributor"?????
lt/fontgtlt/bgt") out.print("(????" new
java.util.Date() ")ltBR/gtlt/pgt")
//?????????? out.println("ltpgtltfont size5
color\"00339\"gtlt/fontgtltfont size5gt"title"lt/fo
ntgtlt/pgtlthr/gt") //???????
out.println(content"lt/pgtlthr/gt")
out.println("lt/bodygt") out.println("lt/htmlgt")
//????????????????
?????? ??????
HTML????? ??
32
?????????????????????????
  • HTML????????????????????
  • ???????????????????????????

request.setCharacterEncoding("Shift_JIS")
33
??????????
  • ???????????????????????????
  • ?????????????????????????????

String contributor request.getParameter("contrib
utor") //??contributor?????????????contributor???
? String type request.getParameter("type") //??
type?????????????type???? String content
request.getParameter(content") //??content??????
???????content????
34
???????????
String contributor request.getParameter("contrib
utor")
Key
Value
contributor ??? title
web.xml????? name web.xml?????????
???
35
HTML??????????????????????
  • ??????????????
  • ????????????????

response.setContentType("text/htmlcharsetShift_J
IS")
36
HTML???????
//HTML?????????????????/ out.println("lthtmlgt")
out.println("ltbody bgcolor\"33CCFF\"
text\"000000\"gt") out.println("lthrgt") //??????
????????? out.print(ltbgtltfont size4gtltpgtcontribu
tor?????lt/fontgtlt/bgt") out.print("(????" new
java.util.Date() ")ltBR/gtlt/pgt") //?????????? out
.println("ltpgtltfont size5gt"title"lt/fontgtlt/pgtlthr/
gt") //??????? out.println(content"lt/pgtlthr/gt") o
ut.println("lt/bodygt") out.println("lt/htmlgt") //
????????????????
??????????????????!?\???????
37
???????? ??
?????
38
????????
???????????????????????????????????????? (????????
???????????????)
???????????????????? HTML?????????????????????????
??????????????? (???Web????????????????)
39
Web??????(??)
  • Web??????????????????????????????
  • (Web???????????????????????????)

GimonKaiketu-Web
WEB-INF
classes
ToukouServlet.class
lib
web.xml
toukou.html
html
index.html
40
????HTML??????
  • text-????????
  • textarea-???????
  • radio-??????
  • checkbox-????????
  • select-???????
  • submit-?????
  • reset-???????
  • ???password?hidden

????WWW???????HTML???????????
http//tohoho.wakusei.ne.jp/www.htm
41
???????!!!
  • ?????????Web?????????????
  • ???????????????????????
  • ????o(-)o
Write a Comment
User Comments (0)
About PowerShow.com