activation.jar mail.jar 파일 들이 필요한데,
http://java.sun.com/products/javamail/downloads/index.html 에서 받을 수 있다.
JavaBeans Activation Framework와 JavaMail 에 포함되어 있다.

이 두 파일은 톰캣의 common/lib나 JRE 등의 경로 내에 있어야 한다.

<%@page contentType = "text/html; charset=euc-kr" %>
<%@ page import="java.util.*,java.io.*,javax.mail.*,javax.mail.internet.*,javax.activation.*" %>
<%
// javamail lib 이 필요합니다.
class MyAuthentication extends Authenticator {
PasswordAuthentication pa;
public MyAuthentication(){
pa = new PasswordAuthentication("아이디", "비밀번호");
}

public PasswordAuthentication getPasswordAuthentication() {
return pa;
}
}

String subject = "Test"; //subject
String msgText = "메일 가니? \n안가니?\n"; //message
String host = "kornet.net"; //smtp mail server
String from = "zxcasd@zxcasd.pe.kr"; //sender email address
String to = "zxcasd12@gmail.com"; //receiver email address

Properties props = new Properties();
props.put("mail.smtp.host", host);
props.put("mail.smtp.auth","true");

Authenticator auth = new MyAuthentication();
Session sess = Session.getInstance(props, auth);

try {
Message msg = new MimeMessage(sess);
msg.setFrom(new InternetAddress(from));
InternetAddress[] address = {new InternetAddress(to)};
msg.setRecipients(Message.RecipientType.TO, address);
msg.setSubject(subject);
msg.setSentDate(new Date());
msg.setContent(msgText,"text/html; charset=euc-kr"); // HTML 형식
// msg.setText(msgText); // TEXT 형식

Transport.send(msg);
out.println("^_^");
} catch (MessagingException mex) {
out.println(mex.getMessage()+"<br>");
out.println("-_-;;.");
}

%>


서버에 따라 빨간 부분 바꿔주고, 전송할 내용 바꿔주면 된다.
(어떤 서버는 smtp 로긴 아이디를 이메일 통째로 입력해야 하는 경우도 있다.)

'Development > Java' 카테고리의 다른 글

CustomTypeHandler를 이용한 Mybatis ResultType 설정  (0) 2014.06.16
JSP의 내장객체  (0) 2014.06.04
SuppressWarnings  (0) 2014.06.02
[펌] jenkins로 서버에 자동 배포하기  (0) 2014.05.22
spring-framework Download  (0) 2014.05.22

상속 방법.

function MyParent(){ }

function MyClassA(){}

MyClassA.prototype = new MyParent ()

constructor를 설정하는 이유는?

MyClassA.prototype = new MyParent();

/* 아래 구문이 실행되기 전까지의 MyClassA.prototype.constructor = MyParent임.

constructor용도는 객체의 타입을 구분하기 위해서 사용됨.

*/
MyClassA.prototype.constructor = MyClassA;

 

'Web > JQuery' 카테고리의 다른 글

checkbox checked 설정  (0) 2014.10.17
Datepicker 대만 번체 zh-TW 번역자료  (0) 2014.07.28
Javascript override 방법  (0) 2014.05.21
jQuery.ajax() 사용시 중복호출 방지하는 방법  (0) 2014.05.21
[IE9 짜증남] IE 버전 체크  (0) 2014.05.21

override 방법

반드시 call(this)를 처럼 해야 됨.

그렇지 않은 경우, Parent의 private메소드를 호출하지 못하게 됨.

MyClassA.prototype.test4 = function() {
alert("MyClassA.prototype.test4" );
MyParent.prototype.test4.call(this);
}

---------------------------------------------------------------------------

예제)

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>무제 문서</title>
<script language="javascript">
function MyParent(nWidth, nHeight)
{
// private 변수 생성.
var width = nWidth;
var height =nHeight;

// 읽기전용 메소드 생성.
this.getWidth = function() {return this.width;}
this.getHeight = function() {return this.height;}
}

// 인스턴스 메소드.
MyParent.prototype.test1 = function()
{
alert("MyParent.prototype.test1 ");
}
// 인스턴스 메소드에서 읽기전용 호출 테스트.
MyParent.prototype.test2 =function ()
{
alert("MyParent.prototype.test2() getWidth = "+this.getWidth());
}

// 인스턴스 메소드에서 읽기전용 호출 테스트.
MyParent.prototype.test3 =function ()
{
alert("MyParent.prototype.test3() getHeight = "+this.getHeight());
}

MyParent.prototype.test4=function()
{
alert("MyParent.prototype.test4");
}

MyParent.prototype.name ="ddan";






function MyClassA(nValue)
{
this.superClass(10,10);
// private 프로퍼티 생성.
this.value = nValue;
}
MyClassA.prototype = new MyParent();
MyClassA.prototype.constructor = MyClassA;
MyClassA.prototype.superClass = MyParent;

// override
MyClassA.prototype.test2 =function()
{
alert("MyClassA.prototype.test2 " );
MyParent.prototype.test2.call(this);
}

// override
MyClassA.prototype.test4 =function()
{
alert("MyClassA.prototype.test4" );
MyParent.prototype.test4.call(this);
}


function on_Load()
{

var objClassA1 = new MyClassA(40);

objClassA1.test1();
// override 한 메소드 호출.
objClassA1.test2();
objClassA1.test3();
// override 한 메소드 호출.
objClassA1.test4();
}


</script>
</head>
<body onLoad="on_Load()">
</body>
</html>

 

'Web > JQuery' 카테고리의 다른 글

checkbox checked 설정  (0) 2014.10.17
Datepicker 대만 번체 zh-TW 번역자료  (0) 2014.07.28
JavaScript Class 상속  (0) 2014.05.21
jQuery.ajax() 사용시 중복호출 방지하는 방법  (0) 2014.05.21
[IE9 짜증남] IE 버전 체크  (0) 2014.05.21

+ Recent posts