1장. asp란?3 웹프로그래밍언어 cgi(commoncgi(commongateway interface) gateway interface)...

27
1장. ASP란? 정보처리학과 정보처리학과 정보처리학과 정보처리학과 서보원 서보원 서보원 서보원 교수 교수 교수 교수

Upload: others

Post on 10-Jan-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 1장. ASP란?3 웹프로그래밍언어 CGI(CommonCGI(CommonGateway Interface) Gateway Interface) Gateway Interface) 언어언어 CGI : 웹서버와외부프로그램사이에데이터를

1장. ASP란?

정보처리학과정보처리학과정보처리학과정보처리학과 서보원서보원서보원서보원 교수교수교수교수

Page 2: 1장. ASP란?3 웹프로그래밍언어 CGI(CommonCGI(CommonGateway Interface) Gateway Interface) Gateway Interface) 언어언어 CGI : 웹서버와외부프로그램사이에데이터를

11

목차

� 웹웹웹웹, , , , 웹웹웹웹 프로그래밍프로그래밍프로그래밍프로그래밍 언어언어언어언어

� ASPASPASPASP란란란란????

� ASP ASP ASP ASP 동작과정동작과정동작과정동작과정

� ASP ASP ASP ASP 개발환경개발환경개발환경개발환경

� ASP 123 ASP 123 ASP 123 ASP 123 예제예제예제예제

Page 3: 1장. ASP란?3 웹프로그래밍언어 CGI(CommonCGI(CommonGateway Interface) Gateway Interface) Gateway Interface) 언어언어 CGI : 웹서버와외부프로그램사이에데이터를

22

웹(Web, World Wide Web, WWW)

� 웹웹웹웹? ? ? ? � 하이퍼텍스트를 제공하는 인터넷 서비스

� 클라이언트클라이언트클라이언트클라이언트////서버서버서버서버� 클라이언트 : 요청 프로그램

� 서버 : 응답 프로그램

� 웹웹웹웹 서버서버서버서버////클라이언트클라이언트클라이언트클라이언트� 웹 클라이언트 : 웹 서비스를 요청하는 프로그램

(웹 브라우저)

� 웹 서버 : HTTP 프로토콜을 사용해 웹 페이지를제공하는 프로그램(IIS, Apache 등)

Page 4: 1장. ASP란?3 웹프로그래밍언어 CGI(CommonCGI(CommonGateway Interface) Gateway Interface) Gateway Interface) 언어언어 CGI : 웹서버와외부프로그램사이에데이터를

33

웹 프로그래밍 언어

� CGI(CommonCGI(CommonCGI(CommonCGI(Common Gateway Interface) Gateway Interface) Gateway Interface) Gateway Interface) 언어언어언어언어

� CGI : 웹 서버와 외부 프로그램 사이에 데이터를

주고받기 위한 표준 규약(방법)

� 일반적인 프로그래밍 언어를 사용(C, VB 등)

� 서버서버서버서버 스크립트스크립트스크립트스크립트 언어언어언어언어

� DB에 대한 처리가 쉽고, 프로그래밍인 쉬운 스크립

트 언어를 사용

� ASP, PHP, JSP 등

Page 5: 1장. ASP란?3 웹프로그래밍언어 CGI(CommonCGI(CommonGateway Interface) Gateway Interface) Gateway Interface) 언어언어 CGI : 웹서버와외부프로그램사이에데이터를

44

웹 스크립트 언어

� 클라이언트클라이언트클라이언트클라이언트 측측측측(client(client(client(client----side) side) side) side) 언어언어언어언어

� 클라이언트인 웹 브라우저에서 해석.실행되는 언어

� JavaScript, VBScript 등

� 서버서버서버서버 측측측측(server(server(server(server----side) side) side) side) 언어언어언어언어

� 서버 측에서 해석되어 그 결과만이 클라이언트에 전

송되는 언어

� ASP, PHP, JSP

Page 6: 1장. ASP란?3 웹프로그래밍언어 CGI(CommonCGI(CommonGateway Interface) Gateway Interface) Gateway Interface) 언어언어 CGI : 웹서버와외부프로그램사이에데이터를

55

ASP란?

� Active Server PagesActive Server PagesActive Server PagesActive Server Pages� 1996년에 탄생

� Server-side, Windows platform,HTML embedded script language

� MSMSMSMS의의의의 동적인동적인동적인동적인 웹웹웹웹 페이지페이지페이지페이지 작성도구작성도구작성도구작성도구� 동적인 웹 페이지를 작성할 수 있는 웹 프로그래밍

언어 예) 게시판, 쇼핑몰 등

� 지원지원지원지원 환경환경환경환경� IIS 웹 서버 6.0 (윈도우 2003)

� IIS 웹 서버 5.1 (윈도우 XP Pro.)

Page 7: 1장. ASP란?3 웹프로그래밍언어 CGI(CommonCGI(CommonGateway Interface) Gateway Interface) Gateway Interface) 언어언어 CGI : 웹서버와외부프로그램사이에데이터를

66

ASP 용도

� 기업기업기업기업, , , , 개인개인개인개인 홈페이지홈페이지홈페이지홈페이지� 게시판

� 회원관리

� 업무용업무용업무용업무용 웹웹웹웹 어플리케이션어플리케이션어플리케이션어플리케이션� 데이터베이스 관련 업무

� 도서 검색

� 은행의 계정 관리

Page 8: 1장. ASP란?3 웹프로그래밍언어 CGI(CommonCGI(CommonGateway Interface) Gateway Interface) Gateway Interface) 언어언어 CGI : 웹서버와외부프로그램사이에데이터를

77

ASP 문서 전송과정

� HTMLHTMLHTMLHTML문서문서문서문서 전송과정전송과정전송과정전송과정

� ASPASPASPASP문서문서문서문서 전송과정전송과정전송과정전송과정

Page 9: 1장. ASP란?3 웹프로그래밍언어 CGI(CommonCGI(CommonGateway Interface) Gateway Interface) Gateway Interface) 언어언어 CGI : 웹서버와외부프로그램사이에데이터를

88

HTML 문서 전송과정

웹웹웹웹 브라우저브라우저브라우저브라우저 웹웹웹웹 서버서버서버서버((((www.abcd.comwww.abcd.comwww.abcd.comwww.abcd.com))))

���� 요청요청요청요청

((((index.html)index.html)index.html)index.html)���� 파일파일파일파일 시스템에서시스템에서시스템에서시스템에서 문서검색문서검색문서검색문서검색

Index.htmlIndex.htmlIndex.htmlIndex.htmlHome.aspHome.aspHome.aspHome.aspDoc1.htmlDoc1.htmlDoc1.htmlDoc1.html

ImagesImagesImagesImages. . .. . .. . .. . .

http://http://http://http://www.abcd.com/index.htmlwww.abcd.com/index.htmlwww.abcd.com/index.htmlwww.abcd.com/index.html 요청요청요청요청

����문서문서문서문서 제공제공제공제공

((((index.htmlindex.htmlindex.htmlindex.html))))

인터넷인터넷인터넷인터넷인터넷인터넷인터넷인터넷

Page 10: 1장. ASP란?3 웹프로그래밍언어 CGI(CommonCGI(CommonGateway Interface) Gateway Interface) Gateway Interface) 언어언어 CGI : 웹서버와외부프로그램사이에데이터를

99

URL 주소 형식

� http://www.abcd.com/index.html

프로토콜 구분자 도메인주소 경로 문서이름

� URL 형식프로토콜 ://주소[:포트번호]/문서이름

Page 11: 1장. ASP란?3 웹프로그래밍언어 CGI(CommonCGI(CommonGateway Interface) Gateway Interface) Gateway Interface) 언어언어 CGI : 웹서버와외부프로그램사이에데이터를

1010

ASP 문서 전송과정

웹웹웹웹 브라우저브라우저브라우저브라우저 웹웹웹웹 서버서버서버서버((((www.abcd.comwww.abcd.comwww.abcd.comwww.abcd.com))))

���� 요청요청요청요청

((((index.asp)index.asp)index.asp)index.asp) ���� 파일파일파일파일 시스템에서시스템에서시스템에서시스템에서 문서검색문서검색문서검색문서검색

Index.aspIndex.aspIndex.aspIndex.aspHome.aspHome.aspHome.aspHome.aspDoc1.htmlDoc1.htmlDoc1.htmlDoc1.html

ImagesImagesImagesImages. . .. . .. . .. . .

http://http://http://http://www.abcd.com/index.awww.abcd.com/index.awww.abcd.com/index.awww.abcd.com/index.aspspspsp 요청요청요청요청

ASP.DLLASP.DLLASP.DLLASP.DLL���� ASP ASP ASP ASP 코드코드코드코드 해석해석해석해석

Index.aspIndex.aspIndex.aspIndex.asp((((순수순수순수순수 HTMLHTMLHTMLHTML문서문서문서문서))))

����문서문서문서문서 제공제공제공제공

((((index.aspindex.aspindex.aspindex.asp))))

인터넷인터넷인터넷인터넷인터넷인터넷인터넷인터넷

Page 12: 1장. ASP란?3 웹프로그래밍언어 CGI(CommonCGI(CommonGateway Interface) Gateway Interface) Gateway Interface) 언어언어 CGI : 웹서버와외부프로그램사이에데이터를

1111

ASP.DLL의 동작 방식� 저장저장저장저장 위치위치위치위치

� IIS를 설치하면windows\system32\inetsrv 폴더에 자동 설치된다.

� 동작동작동작동작 방식방식방식방식� ASP 파일을 분석하여

서버 측 코드가 없으면바로 IIS에 전달해서 클라이언트로 보내고,

� 서버 측 코드가 있으면스크립트를 줄 단위로해석해서 그 결과를 IIS에 전달하여 클라이언트로 전송한다.

Page 13: 1장. ASP란?3 웹프로그래밍언어 CGI(CommonCGI(CommonGateway Interface) Gateway Interface) Gateway Interface) 언어언어 CGI : 웹서버와외부프로그램사이에데이터를

1212

ASP 개발환경

� MS MS MS MS 웹웹웹웹 서버서버서버서버 + + + + 데이터베이스데이터베이스데이터베이스데이터베이스� IIS + SQL Server,Access

� ODBC, OLEDB

� 데이터베이스 연동 지원

� 사용자사용자사용자사용자 환경환경환경환경� 웹 브라우저

Page 14: 1장. ASP란?3 웹프로그래밍언어 CGI(CommonCGI(CommonGateway Interface) Gateway Interface) Gateway Interface) 언어언어 CGI : 웹서버와외부프로그램사이에데이터를

1313

IIS 웹 서버 설치 및 확인

� 윈도우윈도우윈도우윈도우 XP pro. XP pro. XP pro. XP pro. 기준기준기준기준� 설치 CD 이용 별도 설치

� 설치 후 정상적인 동작을 확인하는 것이 필요

� 웹 홈페이지의 기본문서 제공을 확인

Page 15: 1장. ASP란?3 웹프로그래밍언어 CGI(CommonCGI(CommonGateway Interface) Gateway Interface) Gateway Interface) 언어언어 CGI : 웹서버와외부프로그램사이에데이터를

1414

IIS 웹 서버 설정(Windows XP Pro.)

� 설정메뉴설정메뉴설정메뉴설정메뉴� 제어판 – 성능 및 유지관리- 관리도구 –

인터넷정보서비스

Page 16: 1장. ASP란?3 웹프로그래밍언어 CGI(CommonCGI(CommonGateway Interface) Gateway Interface) Gateway Interface) 언어언어 CGI : 웹서버와외부프로그램사이에데이터를

1515

C:\WINDOWS\system32\drivers\etc\services 파일에 정의되어 있다.

Page 17: 1장. ASP란?3 웹프로그래밍언어 CGI(CommonCGI(CommonGateway Interface) Gateway Interface) Gateway Interface) 언어언어 CGI : 웹서버와외부프로그램사이에데이터를

1616

Page 18: 1장. ASP란?3 웹프로그래밍언어 CGI(CommonCGI(CommonGateway Interface) Gateway Interface) Gateway Interface) 언어언어 CGI : 웹서버와외부프로그램사이에데이터를

1717

/ vs. c:\inetpub\wwwroot

� / = / = / = / = c:c:c:c:\\\\inetpubinetpubinetpubinetpub\\\\wwwrootwwwrootwwwrootwwwroot

� 홈홈홈홈 디렉터리디렉터리디렉터리디렉터리� 웹 서버가 관리하는 최상위 디렉토리

� 브라우저에서 보는 /(루트) 디렉터리

� 실제 시스템에서는 웹 서버에 의해서 지정됨

� C:\inetpub\wwwroot 는 IIS 기본 설정

Page 19: 1장. ASP란?3 웹프로그래밍언어 CGI(CommonCGI(CommonGateway Interface) Gateway Interface) Gateway Interface) 언어언어 CGI : 웹서버와외부프로그램사이에데이터를

1818

기본 문서 : 클라이언트가 파일 이름을 지정하지 않은경우에 기본으로 전송하는 파일

Page 20: 1장. ASP란?3 웹프로그래밍언어 CGI(CommonCGI(CommonGateway Interface) Gateway Interface) Gateway Interface) 언어언어 CGI : 웹서버와외부프로그램사이에데이터를

1919

<HTML><HTML><HTML><HTML><HEAD><HEAD><HEAD><HEAD><TITLE>index <TITLE>index <TITLE>index <TITLE>index 문서문서문서문서</TITLE></TITLE></TITLE></TITLE>

</HEAD></HEAD></HEAD></HEAD><BODY><BODY><BODY><BODY><H2><H2><H2><H2>기본기본기본기본 페이지입니다페이지입니다페이지입니다페이지입니다.</H2>.</H2>.</H2>.</H2>

</BODY></BODY></BODY></BODY></HTML></HTML></HTML></HTML>

Default.asp(27페이지)

※ localhost : 원격지 컴퓨터들에 대한 상대적인 의미로off-line 상태로 바로 액세스가능한 PC 자신을 의미한다=자신의 컴퓨터=127.0.0.1

Page 21: 1장. ASP란?3 웹프로그래밍언어 CGI(CommonCGI(CommonGateway Interface) Gateway Interface) Gateway Interface) 언어언어 CGI : 웹서버와외부프로그램사이에데이터를

2020

가상 디렉터리

� 모든모든모든모든 파일을파일을파일을파일을 c:c:c:c:\\\\inetpubinetpubinetpubinetpub\\\\wwwrootwwwrootwwwrootwwwroot 밑에밑에밑에밑에 둘둘둘둘 수수수수있나있나있나있나????� C:\ 의 크기 제한

� D:\, c:\user 등 다른 경로의 파일 제공 시가상 디렉터리 개념 등장

� 가상가상가상가상 디렉터리디렉터리디렉터리디렉터리 필요성필요성필요성필요성� 웹에 제공되는 문서가 모두 시스템의 홈 디렉터리에

서 제공될 필요가 없다.

� 웹 서버의 경로 매핑으로 가상 디렉터리 제공 가능

� 일관성 제공

Page 22: 1장. ASP란?3 웹프로그래밍언어 CGI(CommonCGI(CommonGateway Interface) Gateway Interface) Gateway Interface) 언어언어 CGI : 웹서버와외부프로그램사이에데이터를

2121

가상 디렉터리

� 예예예예))))� 문서경로 www.abcd.com/util/util1.html

� 가상디렉터리 미 설정 시

� C:C:C:C:\\\\inetpubinetpubinetpubinetpub\\\\wwwrootwwwrootwwwrootwwwroot\util

� 가상디렉터리 설정 시

� C:\util 또는 c:\temp\util, …

Page 23: 1장. ASP란?3 웹프로그래밍언어 CGI(CommonCGI(CommonGateway Interface) Gateway Interface) Gateway Interface) 언어언어 CGI : 웹서버와외부프로그램사이에데이터를

2222

Hello.asp : ASP 예제

� 간단한 메시지 제공하는 ASP 예제

� 실행

� http://localhost/asp3/hello.asp

� 점검 사항

1. 웹 서버(IIS) 실행 여부

2. ASP 파일 위치 확인

� C:\inetpub\wwwroot\asp3 폴더

Page 24: 1장. ASP란?3 웹프로그래밍언어 CGI(CommonCGI(CommonGateway Interface) Gateway Interface) Gateway Interface) 언어언어 CGI : 웹서버와외부프로그램사이에데이터를

2323

<<<<HTML>HTML>HTML>HTML><HEAD> <HEAD> <HEAD> <HEAD>

<TITLE> Hello ASP <TITLE> Hello ASP <TITLE> Hello ASP <TITLE> Hello ASP </TITLE></TITLE></TITLE></TITLE>

</HEAD></HEAD></HEAD></HEAD><BODY><BODY><BODY><BODY>

<P><P><P><P><% for i = 1 to 3 step 1 %><% for i = 1 to 3 step 1 %><% for i = 1 to 3 step 1 %><% for i = 1 to 3 step 1 %>

Hello ASP student <% = i %><BR><BR>Hello ASP student <% = i %><BR><BR>Hello ASP student <% = i %><BR><BR>Hello ASP student <% = i %><BR><BR><% next %><% next %><% next %><% next %>

</BODY></BODY></BODY></BODY></HTML> </HTML> </HTML> </HTML>

Hello.asp 코드(34페이지)

Page 25: 1장. ASP란?3 웹프로그래밍언어 CGI(CommonCGI(CommonGateway Interface) Gateway Interface) Gateway Interface) 언어언어 CGI : 웹서버와외부프로그램사이에데이터를

2424

Hello.asp 해석 과정

Page 26: 1장. ASP란?3 웹프로그래밍언어 CGI(CommonCGI(CommonGateway Interface) Gateway Interface) Gateway Interface) 언어언어 CGI : 웹서버와외부프로그램사이에데이터를

2525

ASP 코드 해석

<% for i = 1 to 3 step 1 %><% for i = 1 to 3 step 1 %><% for i = 1 to 3 step 1 %><% for i = 1 to 3 step 1 %>Hello ASP student <% = i %><BR><BR>Hello ASP student <% = i %><BR><BR>Hello ASP student <% = i %><BR><BR>Hello ASP student <% = i %><BR><BR>

<% next %><% next %><% next %><% next %>

Hello ASP student 1 <BR><BR>Hello ASP student 1 <BR><BR>Hello ASP student 1 <BR><BR>Hello ASP student 1 <BR><BR>Hello ASP student 2 <BR><BR>Hello ASP student 2 <BR><BR>Hello ASP student 2 <BR><BR>Hello ASP student 2 <BR><BR>Hello ASP student 3 <BR><BR>Hello ASP student 3 <BR><BR>Hello ASP student 3 <BR><BR>Hello ASP student 3 <BR><BR>

� ASP 코드는 <% 와 %> 사이에 둔다.

�ASP에서는 연산자, 제어문 등을

VBScript를 사용하여 처리한다.

�=는 값을 출력한다.

해석

Page 27: 1장. ASP란?3 웹프로그래밍언어 CGI(CommonCGI(CommonGateway Interface) Gateway Interface) Gateway Interface) 언어언어 CGI : 웹서버와외부프로그램사이에데이터를

2626

정리

� 1111장장장장� 웹, 웹 프로그래밍 언어

� ASP란?

� ASP 동작과정

� ASP 개발환경

� ASP 123 예제

� 2222장장장장 VBScriptVBScriptVBScriptVBScript� ASP 프로그램 코드 작성을 위한 스크립트언어