Transcript Document
제 15 장
파일 업로드와
메일 보내기
2008 2학기
인터넷비즈니스과 강 환수 교수
자카르타 프로젝트
아파치 소프트웨어 재단
(AFC: Apache
Foundation Consortium)
의 하위 기관
아파치 소프트웨어 라이센스를
바탕으로 하는 공동 개발방식을
장려
다양한 오픈 소스 기반의 자바
솔류션
자카르타 프로젝트
톰캣
JSTL도 Taglibs 이름의 프로젝
트에서 개발한 제품
commons
2
commons.apache.org
다양한 컴포넌트 제공
3
필요 라이브러리
파일 업로드
commons-fileupload-1.2.1.jar
commons-io-1.4.jar
메일
commons-email-1.1.jar
mail.jar
4
자카르타 James
메일 엔진 설치
james.apache.org
• james-binary-2.3.1.zip
5
파일 업로드 프로그램 작성
파일 업로드 폼
fileUpload.html
<h2> 파일 업로드 예제</h2><hr>
<form method="post" action="fileUpload.jsp" enctype="multipart/form-data">
사용자: <input type="text" name="user"><br><hr>
첨부파일1: <input type="file" size=50 name="file1"><br>
첨부파일2: <input type="file" size=50 name="file2"><br>
<input type="submit" value="전송">
</form>
파일 업로드 프로그램
fileUpload.jsp
6
메일 보내기에 필요 정보
주요 클래스
패키지 org.apache.commons.mail에 속하는 클래스 8개로 구성된
매우 작은 라이브러리
메일 종류
메일 클래스
간편 메일
SimpleEmail
첨부 메일
MultiPartEmail
HTML 메일
HtmlEmail
관련 클래스
메시지만 있는 간단한 메일 보내기
EmailAttachment
클래스 EmailAttachment에 첨부 내용을
붙여 메일 보내기
HTML 지원하는 내용을 메일로 보내기
메일에 필요한 정보
기능
문자셋
SMTP 서버
보내는 사람(주소, 이름, 문자셋)
받는 사람(주소, 이름, 문자셋)
제목
7
메일 보내기 프로그램 작성
SMTP 서버 실행
James 실행
메일 보내기 프로그램
sendmail.jsp
8
한글 처리와 첨부 파일, HTML 메일 보내기
한글메일 처리 예제
sendmaileuckr.jsp
• SimpleEmail email = new SimpleEmail();
• email.setCharset(charSet);
구글 SMTP 서버 이용 메일
email.setAuthentication(hostSMTPid, hostSMTPpasswd);
email.setTLS(true);
첨부파일 예제
sendmailAttachment.jsp
HTML 메일 예제
sendhtmlmail.jsp
9
www.dongyang.ac.kr