Tomcat???Web???????????? - PowerPoint PPT Presentation

About This Presentation
Title:

Tomcat???Web????????????

Description:

Servlet (1) Tomcat Web 2003 5 15 Web ... – PowerPoint PPT presentation

Number of Views:138
Avg rating:3.0/5.0
Slides: 21
Provided by: Ryuhei
Category:
Tags: apache | tomcat | web

less

Transcript and Presenter's Notes

Title: Tomcat???Web????????????


1
Tomcat???Web????????????
Servlet??(1)
????? ???? 2003?5?15?
2
?????
  • Web?????????????????
  • ????Web???????????????
  • CGI?Servlet??????????????
  • Web???????????? ??????????
  • web.xml?????????????
  • Servlet??????????????? ??????

3
Web??????????
??????HTTP????????????????????
Web?????????
???????Web?????????
?????? ? Web???
Web???????????????????
????????????????????? ????????Web???????
?SFC?????????
4
Web??????????
SFC??????????????? ????????????????????
???? ????????? ???? ?????????????
?????????
??????????????????Web???????????
????????????????????????????? ????????????????????
??Web?????????
???????Web?????????????????????????
5
Web???????????
??????????Web?????????
??
???? ????
??A
??
???? ????
??????HTTP????????
??B
??
???? ????
??C
????????????
??????????????????????
6
?????????????
  • ???Web??????????????
  • Web????Web??????????????????
  • HTTP?????
  • ???????????????Java????????????
  • Web???????????????????
  • ?Web??????????????????
  • ?Web???????????????????
  • Tomcat??????????????????

??????????? Tomcat
???????Web???? HTTP?????/?????????? ?????????????
7
????????
  • ?????????Java??????
  • ??????(??????)??HTTP??????????????
  • HTTP???????????????????HTTP???????????
  • ??????????????????????????

HTTP?????
java HOGE
??
??
  • ???????????????????????

8
??????????
import java.io. import javax.servlet.
import javax.servlet.http. public class
HelloWorldServlet extends HttpServlet public
void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException
// ContentType???
response.setContentType("text/html
charsetShift_JIS") //
???PrintWriter??? PrintWriter out
response.getWriter() // ??
out.println("lthtmlgt")
out.println("ltheadgt")
out.println("lttitlegtHello World
Servletlt/titlegt")
out.println("lt/headgt")
out.println("ltbodygt")
out.println("Hello World")
out.println("lt/bodygt")
out.println("lt/htmlgt")
Servlet???????????????
GET????????????????? ???????
HTML??????????
HTML??????
9
Tomcat??????????????????
  • ?Tomcat?????
  • ?Web?????
  • http//localhost8080/examples/servlet/HelloWo
    rldExample
  • ?????
  • ???????????????

10
??????????????HTTP?????/??????????????????
?????????GET?????????????
  • ??????HTTP???????????????????

HTTP/1.1 200 OK Content-Type text/html Date
Wed, 08 May 2002 073258 GMT Server Apache
Tomcat/4.0.1-b1 (HTTP/1.1 Connector) Connection
close lthtmlgt ltbody bgcolorwhitegt lth1gtHello
World!lt/h1gt lt/bodygt lt/htmlgt ????????????????
?????????????????? ?????????????? ????????????????
11
???Web???????????
??????Web??????????????
?Web??????????????
?WEB-INF?????????
?web.xml???????
????????
??????????????
?????????????
???????????Web??????????????
12
Web??????
  • TOMCAT_HOME/webapps/???????????????
  • TOMCAT_HOME/webapps/Web????

Web??????????????? ???????????????
http//localhost8080/Web????/??
??Web??????????
TOMCAT_HOME/
webapps
13
Web???????????????
  • Web???????????????

/Web????/WEB-INF/classes/ /WEB-INF/lib/
/WEB-INF /web.xml
/index.html
  • Web??????????????? (web.xml????)

??????????? http//?????????/web????/servlet/???
? ?http//localhost8080/examples/servlet/Hello
WorldServlet index.html????? http//?????????/we
b????/index.html
14
????????
  • TOMCAT_HOME/webapps/Web???????WEB-INF???????????
  • ???????????????????classes?????????
  • ???????????????????Web ??????????????????????????
    ???????????????????????????????

lib?????????(???????)
Web????
15
CGI?Web???????
  • CGI???????Java?Web????2??????????????

/public_html
????????? ???????? ?????
taikuLogin.html
?
/cgi
taiikuLogin.cgi
2??????
?????????????Web?????????! Web??????????? CGI?????
????????????
16
???????Web???????
  • ??????Java?Web?????????1??????????????????????????
    ????????????1??????????????

?
2??????
Web???????????????????????? Web??????????? ??????J
ava?Web???????????
17
Web??????
  • ??????????????????WEB????????????????
    ??web.xml ?WEB-INF????????
  • web.xml????Web?????????????????!
  • ???????????????????
  • ???????????????????????????????????????/JSP???
    ???????/JSP???????MIME?????????????????????????
    ????????????
  • ??????????????????????????

??????????????
Web????
WEB-INF
classes
lib
18
web.xml???????
???????????????URL????????????????????????????????
????? ?http//localhost8080/examples/greeting..ht
ml????URL??????????????HelloWorldServlet??????????
?????????? lt?xml version"1.0"
encoding"ISO-8859-1"?gt lt!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application
2.3//EN" "http//java.sun.com/dtd/web-app_2_3.dtd"
gt ltweb-appgt ltservletgt ltservlet-namegtHello
WorldServletlt/servlet-namegt
ltservlet-classgtHelloWorldServletlt/servlet-classgt
lt/servletgt ltservlet-mappinggt
ltservlet-namegtHelloWorldServletlt/servlet-namegt
lturl-patterngt/greeting.htmllt/url-patterngt
lt/servlet-mappinggt lt/web-appgt
???????? ?????????
???????? ??????? URL??????
19
server.xml????????
server.xml??????????????????????????? Tomcat?????
????????????????Web??????????????server.xml???ltHos
tgtlt/Hostgt?????????Web??????????????????? ltHost
name"localhost" debug"0" appBase"webapps"
unpackWARs"true" autoDeploy"true"gt ltContext
path"/test" docBase"C\programing\java\test"
debug"0"/gt lt/Hostgt ?path??????URL???????????????
?docBase?????????????Web????????????????????????
??????????http//???????IP????8080/test/????UR
L?????????? C\programing\java\test
???????????Web???????????????????
????????Web?????????Tomcat????????????????????
20
??????
  • 1.????????????????????????????Web??????
  • ?TOMCAT_HOME/conf/web.xml ?273???278????????????
    ??????
  • 2.???Web??????????????????????????????????????????
    ????????HTML????????????????????
  • 3.????Web????web.xml?????
  • http//localhost8080/date/clock.html
  • ????????TimeServlet???????????
  • ?????????????????
  • 4.????Web????Tomcat?????????????????
  • ???server.xml????????????????????
  • ???????
Write a Comment
User Comments (0)
About PowerShow.com