КонстрПЗ_ПI_ЛР2014_ч2
.pdf61
Java Eclipse, ' . @ K -, e Tomcat ( . . 4.4).
> 4.4 – ? Tomcat-
/ work, WEB-INF WEB-INF/src ',
.
4.2.3 ] / }# Z "/
? – , . e
Eclipse HelloWorldServlet
HelloWorld. @ :
public class HelloWorldServlet extends HttpServlet {
public void service(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException { PrintWriter writer = response.getWriter(); writer.println("Hello, World!"); writer.close();
}
}
; , ' Ctrl+Shift+O
import. Eclipse
:
–java.io.IOException;
–java.io.PrintWriter;
–javax.servlet.ServletException;
62
–javax.servlet.HttpServlet;
–javax.servlet.HttpServletRequest;
–javax.servlet.HttpServletResponse.
? , i
HttpServlet service(). service()
K e , -
' . @ K -
, ' . 5 -
, K -
, i 0. ' , ,
doget(), service() K , i
.
service() K getwriter()
, i
. & K . z , i - 0 *: K , -
0 .
4.2.4 2% Z web-. . "
> Java-0 ,
* *.
A ' 0 0 e
HelloWorld Properties. A 0 Tomcat
. & ' , K
:
/HelloWorld
< * e -
Tomcat. ;
conf/Catalina/localhost. Xml-*. -
, * HelloWorld.xml. & *. z * K WebTomcat.
<Context path="/HelloWorld" reloadable="true" docBase="path to your project\HelloWorld"
workDir="path to your project\HelloWorld\work" />
& Tomcat K * , i
* , e (
).
63
5 0 WebTomcat K
* web.xml, i
WEB-INF e . 5 *
:
<!DOCTYPE web-app PUBLIC '-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN' 'http://java.sun.com/dtd/web-
app_2_3.dtd'> <web-app>
<servlet> <servlet-name>hello</servlet-name>
<servlet-class>HelloWorldServlet</servlet-class> </servlet>
<servlet-mapping> <servlet-name>hello</servlet-name> <url-pattern>/hello</url-pattern>
</servlet-mapping> </web-app>
z * K WebTomcat. ` servletname K *. ` servlet-class ' K ' , i K
– HelloWorldServlet . ` servletmapping K Tomcat, i URL /hello ' K ,
' .
x i * , ' -
Tomcat ' .
@ K Tomcat Web-
URL . A
Tomcat, 0
(i Tomcat ' 0K, -
). & e ' Tomcat, Web-
URL:
http://localhost:8080/Helloworld/hello
& i .
4.3 %. Z .
4.3.15 .
4.3.2> 0 IDE Eclipse. ? K
GET POST
64
( . . 4.1) -
* HTML. & ,
0 K ' 0 -
0 Mercurial.
< 4.1 –
@
1A x2+ B x + C = 0. 0 : A, B, C.
' . 0 -
2:
, .
&, ' . -
30 : e
, -, ' .
' . 0
4: -
, .
0 i, 0 : A1
5x + B1 y + C1 = 0 A2 x + B2 y + C2 = 0. 0
: A1, A2, B1, B2, C1, C2.
i, K
6(x, y, z) . 0
: i
, .
75 i . 0
: .
4.3.3> - Apache Tomcat.
4.3.4@ . & -
– . & 0 *-
0 Mercurial.
4.3.5& * .
4.3.65* .
65
4.4 1$ !%$
4.4.1< .
4.4.24 ,
.
4.4.3< , i K -
.
4.4.4@ * ' - * *.
4.4.55 ,
IDE Eclipse, -
.
4.4.6> - .
4.4.7@, i ,
' ' 0
.
4.5 /^$ Z
4.5.1ƒ ?
4.5.20 0 ?
4.5.3x IDE
Eclipse?
4.5.4x debug ?
4.5.55 e ?
4.5.6x ' CGI?
4.5.7x WAR-*?
4.5.8x e 0?
4.5.9x K 0
' 0 ' ?
4.5.10x ' *, 0 HTTP?
4.5.11x '
e?
66
5 P G G G P 5
G G P JSP
5.1 #
Apache Tomcat
Java Server Pages (JSP) Apache Tomcat IDE Eclipse.
5.2 "$ # # S$ %$. 1$
- Š. JSP, K
* ( -
).
/ JSP (Java Server Pages, Java) –
, - * webJava. JSP – *, i K K -
HTML XHTML, XmlJSP.
* JSP 0 e .jsp,
firstpage.jsp. & e K JSP -
JSP 0, web- 0K -
. ? * JSP 2.0 K
JSP * 0 . & -
K 'K- .
/ JSP, , Jasper Tomcat,
. Web-
0K
. z 0 - 0,
( ' , i , i
K).
> 0 ' K JSP
, 0-
. ? JSP -
, 0 Java K *-
67
0 * 0, HTML DHTML, - e 0 Xml- .
A , i JSP- -
i Eclipse: 0 0 e -
New->JSP ( . . 5.1).
> 5.1 – ? JSP-
' JSP- XML-*, -
0 JSP-A, 0 -
XML- . ? * JSP 2.0 K
* e .jspx. x '
JSP- , '.
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib uri='http://java.sun.com/jsp/jstl/core' prefix='c'%> <jsp:useBean id="date" class="java.util.Date" />
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
68
<title>JSP Page</title>
</head>
<body>
<h1>wGP/S*6 </h1> <c:out value="${date}" />
</body>
</html>
< ' . x i -
, «?-
» 0 0.
& e ,
, ' , i JSP- 0K
* Java 0K .
5.3 %. Z .
5.3.15 .
5.3.2? - JSP-
,
.
: &2„, ', , , -
, ' e , ' -
- .
; JSP- :
– ' ( ' 0 -
– 0 Delete '-
);
– ;
– 0 .
& , ’ 0 , -
.
& - 0 ' -
0 0 Mercurial.
5.3.3> - Apache Tomcat.
5.3.4@ - . &
– . & 0 * 0 Mercurial.
5.3.5& * .
5.3.65* .
69
5.4 1$ !%$
5.4.1< .
5.4.24 , -
' .
5.4.3< .
5.4.4< JSP- .
5.4.5@ * - '
* *.
5.4.65 , -
IDE Eclipse, -
.
5.4.7&
- .
5.4.8> - .
5.4.9@, i ,
' ' 0
.
5.5 /^$ Z
5.5.1ƒ JSP 0?
5.5.2/ JSP, – ?
5.5.3& ' JSP .
5.5.4ƒ K 0 JSP?
5.5.5x - 0 JSP?
5.5.65 e JSP.
5.5.7x 0 0 ’K?
5.5.8x @ K JSP?
5.5.9x JSP Apache Tomcat?
5.5.10x ' HttpSession mySession = request.getSession(true) HttpSession mySession=request.getSession()?
5.5.11x ' JSP java-
?
70
G NG
1.? ›. › ' &5 / ›. ?. – . :
@, 2002. – 624 .
2./ ?. ? e Š . & -
/ ?. /. –
?. : &, 2007. – 896 .
3.Pfleeger S. L. Software Engineering. Theory and practice /
S.L. Pfleeger. – New Jersey : Printice Hall, 1998. – 576 p.
4.> 0 '
* = Software Engineering 2004: Curriculum Guidelines for Undergraduate Degree Programs in Software Engineering; Computing Curricula 2001: Computer Science: . . – . :
›;< ›<.> «›- › * Š <», 2007. – 462 .
5.Guide to the Software Engineering Body of Knowledge (SWEBOK). – New York : IEEE Publising House, 2004. – 129 p.
6.5 ?. 4. < -
. @ / ?. 4. 5. ?&. : &. – 2002. – 463 .
7.‹ @. @. & '.
Š: . / @. @. ‹. – .: <`›?, 2006. – 608 .
8.• @. 5 Š C++. Š ' /
@. •. – . : ‹, 2003. – 880 .
9.& @. ‹. > 0 -
' * : . . / @. ‹. &, 4. 4. <, 4. ;. <. – . : ›;< ›<.>, 2007. – 462 .
10.v5?< 19.101-77. @ Š Š -
. – @. 1980-01-01. – . : ›- , 1987. – 15 .
11.ISO/IEC 12207:1995. Information Technology – Software Life Cycle Processes. – First edition 1995-08-01. – Switzerland : International Organization for Standardization. – 67 p.