about javamail

hellow hi friend i have one doubt i am new in javamail so i have successfully compiled following javamail program

import javax.mail.Message;

import javax.mail.Session;

import javax.mail.Transport;

import javax.mail.internet.InternetAddress;

import javax.mail.internet.MimeMessage;

import java.net.InetAddress;

import java.util.Properties;

import java.util.Date;

public class sendMail

{

sendMail()

{}

public static void send(String smtpServer, String to, String from, String subject, String body)

{

try

{

Properties props = System.getProperties();

// -- Attaching to default Session, or we could start a new one --

props.put("mail.smtp.host", smtpServer);

Session session = Session.getDefaultInstance(props, null);

// -- Create a new message --

Message msg = new MimeMessage(session);

// -- Set the FROM and TO fields --

msg.setFrom(new InternetAddress(from));

msg.setRecipients(Message.RecipientType.TO,

InternetAddress.parse(to, false));

// -- We could include CC recipients too --

// if (cc != null)

// msg.setRecipients(Message.RecipientType.CC

// ,InternetAddress.parse(cc, false));

// -- Set the subject and body text --

msg.setSubject(subject);

msg.setText(body);

// -- Set some other header information --

msg.setHeader("X-Mailer", "LOTONtechEmail");

msg.setSentDate(new Date());

// -- Send the message --

Transport.send(msg);

System.out.println("Message sent OK.");

}

catch (Exception ex)

{

ex.printStackTrace();

}

}

}

know i want to call this class in my jsp page so please tell me how and how to configure the xml file also i am using tomcat 6.0 ok please if u have solution please solve this problem thanks

[1909 byte] By [abhinay_31a] at [2007-11-27 9:37:32]
# 1

I don't think this question has anything to do with JavaMail.

You would call that class from a JSP the same way you would call any

class from a JSP. And since you're using a static method, you don't

even have to worry about getting an instance of the class. Just think

of it like a "function".

There are examples of using JavaMail from a JSP application in the

JavaMail download bundle, although they're much more sophisticated

than this.

If you're having trouble with basic JSP programming, and the Java EE Tutorial

isn't helping, try the servlet and JSP support forum.

bshannona at 2007-7-12 23:09:02 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...