org.apache.taglibs.mailer2
Class MailTag

java.lang.Object
  extended byjavax.servlet.jsp.tagext.TagSupport
      extended byjavax.servlet.jsp.tagext.BodyTagSupport
          extended byorg.apache.taglibs.mailer2.PartTag
              extended byorg.apache.taglibs.mailer2.MailTag
All Implemented Interfaces:
BodyTag, IterationTag, JspTag, Serializable, Tag
Direct Known Subclasses:
LoadTag, SignTag

public class MailTag
extends PartTag

JSP tag mt:mail is used to construct an e-mail message. It is the root element of this tag library.

mt:mail can have the following child tags: mt:addrecipient, mt:attach, mt:header, mt:part.

The message will be sent unless the var attribute has been set.

Version:
2.0
Author:
Jeroen van Vianen
See Also:
Serialized Form

Field Summary
static String FROM
          The name of the context-param to set as the from address.
static String PASSWORD
          The name of the context-param to set the plain text password to authenticate to the SMTP server.
static String PORT
          The name of the context-param to set the name of the SMTP server port.
static String SERVER
          The name of the context-param to set the name of the SMTP server.
protected  String username
          Username to login to SMTP server.
static String USERNAME
          The name of the context-param to set the username to authenticate to the SMTP server.
static String VERSION
          Version of this tag library.
 
Fields inherited from class org.apache.taglibs.mailer2.PartTag
log
 
Fields inherited from class javax.servlet.jsp.tagext.BodyTagSupport
bodyContent
 
Fields inherited from class javax.servlet.jsp.tagext.TagSupport
id, pageContext
 
Fields inherited from interface javax.servlet.jsp.tagext.BodyTag
EVAL_BODY_BUFFERED, EVAL_BODY_TAG
 
Fields inherited from interface javax.servlet.jsp.tagext.IterationTag
EVAL_BODY_AGAIN
 
Fields inherited from interface javax.servlet.jsp.tagext.Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
 
Constructor Summary
MailTag()
          Default zero-arg constructor.
 
Method Summary
 void addRecipient(String type, Address address)
          Add a recipient to the list of "to" recipients.
 void addReplyTo(Address address)
          Add an e-mail address to the list of reply-to recipients.
 int doAfterBody()
           
 int doEndTag()
           
 int doStartTag()
           
 String getBcc()
          Returns the bcc address.
 String getCc()
          Returns the cc address.
 String getFrom()
          Returns the from address.
 String getImportance()
          Returns the importance of the message, either "low", "normal", or "high".
 String getMimemessage()
          Returns the javax.mail.internet.MimeDataSource object
 String getPassword()
          Returns the password for SMTP authentication.
 int getPort()
          Returns the SMTP server port, default 25.
 String getReplyto()
          Returns the reply-to address.
 String getScope()
          Returns the scope to store the variable in.
static int getScopeType(String scope)
          Returns the scopeType for a given scope name.
 String getServer()
          Returns the name of the SMTP server.
 String getSession()
          Returns the javax.mail.Session object.
 Session getSessionObject()
          Returns a Mail Session object.
 String getSubject()
          Returns the subject of the message.
 String getTo()
          Returns the to attribute.
 String getUsername()
          Returns the username for SMTP authentication.
 String getVar()
          Returns the name of the variable to store the message in.
 boolean isBackground()
          Returns whether the mail should be sent in the background.
 void release()
           
 void setBackground(boolean background)
          Sets the background attribute.
 void setBcc(String bcc)
          Sets the bcc attribute.
 void setCc(String cc)
          Sets the cc attribute.
 void setFrom(String from)
          Sets the from attribute.
 void setImportance(String importance)
          Sets the importance of the message.
 void setMimemessage(String mimemessage)
          Sets the mimemessage attribute.
 void setPassword(String password)
          Sets the password for PLAIN or LOGIN SMTP authentication.
 void setPort(int port)
          Sets the TCP/IP server port, default 25.
 void setReplyto(String replyto)
          Sets the Reply-To address for this message.
 void setScope(String scope)
          Sets the scope where this message should be stored, rather than sent.
 void setServer(String server)
          Sets the SMTP server name.
 void setSession(String session)
          Sets the JNDI lookup for a javax.mail.Session object to be used as the mail Session.
 void setSubject(String subject)
          Sets the subject for this message.
 void setTo(String to)
          Sets the "to" recipients for this message.
 void setUsername(String username)
          Set the login username name for PLAIN or LOGIN SMTP authentication.
 void setVar(String var)
          Sets the var attribute.
 
Methods inherited from class org.apache.taglibs.mailer2.PartTag
addPart, constructMessage, getBody, getContentType, getEncoding, getHeaders, getParts, getType, setBody, setEncoding, setHeader, setType
 
Methods inherited from class javax.servlet.jsp.tagext.BodyTagSupport
doInitBody, getBodyContent, getPreviousOut, setBodyContent
 
Methods inherited from class javax.servlet.jsp.tagext.TagSupport
findAncestorWithClass, getId, getParent, getValue, getValues, removeValue, resetCustomAttributes, setId, setPageContext, setParent, setValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.servlet.jsp.tagext.Tag
getParent, setPageContext, setParent
 

Field Detail

FROM

public static final String FROM
The name of the context-param to set as the from address.

See Also:
Constant Field Values

SERVER

public static final String SERVER
The name of the context-param to set the name of the SMTP server.

See Also:
Constant Field Values

PORT

public static final String PORT
The name of the context-param to set the name of the SMTP server port.

See Also:
Constant Field Values

USERNAME

public static final String USERNAME
The name of the context-param to set the username to authenticate to the SMTP server.

See Also:
Constant Field Values

PASSWORD

public static final String PASSWORD
The name of the context-param to set the plain text password to authenticate to the SMTP server.

See Also:
Constant Field Values

VERSION

public static final String VERSION
Version of this tag library.

See Also:
Constant Field Values

username

protected String username
Username to login to SMTP server.

Constructor Detail

MailTag

public MailTag()
Default zero-arg constructor.

Method Detail

doStartTag

public int doStartTag()
               throws JspException
Specified by:
doStartTag in interface Tag
Overrides:
doStartTag in class PartTag
Throws:
JspException

doAfterBody

public int doAfterBody()
                throws JspException
Specified by:
doAfterBody in interface BodyTag
Overrides:
doAfterBody in class PartTag
Throws:
JspException

doEndTag

public int doEndTag()
             throws JspException
Specified by:
doEndTag in interface Tag
Overrides:
doEndTag in class PartTag
Throws:
JspException

release

public void release()
Specified by:
release in interface Tag
Overrides:
release in class PartTag

addRecipient

public void addRecipient(String type,
                         Address address)
                  throws JspException
Add a recipient to the list of "to" recipients.

Parameters:
type - The type of recipient, either "to", "cc", or "bcc"
address - The address to add
Throws:
JspException - for invalid types

addReplyTo

public void addReplyTo(Address address)
Add an e-mail address to the list of reply-to recipients.

Parameters:
address - The e-mail address to reply-to

getScopeType

public static int getScopeType(String scope)
                        throws JspException
Returns the scopeType for a given scope name.

Parameters:
scope - "request", "page", "session", or "application"
Returns:
The scopeType as found in PageContext
Throws:
JspException - For an invalid scope

getSessionObject

public Session getSessionObject()
                         throws JspException
Returns a Mail Session object. This instance is based upon the value of one of the following attributes (in this order):

Returns:
A Session instance
Throws:
JspException - Upon error

getBcc

public String getBcc()
Returns the bcc address.

Returns:
The bcc address

setBcc

public void setBcc(String bcc)
Sets the bcc attribute.

Parameters:
bcc - The e-mail address that will get a BCC of this message

getCc

public String getCc()
Returns the cc address.

Returns:
The cc address

setCc

public void setCc(String cc)
Sets the cc attribute.

Parameters:
cc - The e-mail address that will get a CC of this message

getFrom

public String getFrom()
Returns the from address.

Returns:
The from address

setFrom

public void setFrom(String from)
Sets the from attribute.

Parameters:
from - The e-mail address of the sender of this message

getImportance

public String getImportance()
Returns the importance of the message, either "low", "normal", or "high".

Returns:
The importance.

setImportance

public void setImportance(String importance)
Sets the importance of the message.

Parameters:
importance - Either "low", "normal", or "high"

getMimemessage

public String getMimemessage()
Returns the javax.mail.internet.MimeDataSource object

Returns:
The javax.mail.internet.MimeDataSource.

setMimemessage

public void setMimemessage(String mimemessage)
Sets the mimemessage attribute.

Parameters:
mimemessage - The name of a JNDI lookup MimePartDataSource

getPassword

public String getPassword()
Returns the password for SMTP authentication.

Returns:
The password

setPassword

public void setPassword(String password)
Sets the password for PLAIN or LOGIN SMTP authentication.

Parameters:
password - Plain text password for authentication

getPort

public int getPort()
Returns the SMTP server port, default 25.

Returns:
The SMTP server port

setPort

public void setPort(int port)
Sets the TCP/IP server port, default 25.

Parameters:
port - The port number

getReplyto

public String getReplyto()
Returns the reply-to address.

Returns:
The reply-to address

setReplyto

public void setReplyto(String replyto)
Sets the Reply-To address for this message.

Parameters:
replyto - The address of the person to whom this message should be replied

getScope

public String getScope()
Returns the scope to store the variable in.

Returns:
The scope

setScope

public void setScope(String scope)
Sets the scope where this message should be stored, rather than sent.

Parameters:
scope - The name of the scope, either "page", "request", "session", or "application".

getServer

public String getServer()
Returns the name of the SMTP server.

Returns:
The server name

setServer

public void setServer(String server)
Sets the SMTP server name.

Parameters:
server - Name of the mail server, default "localhost".

getSession

public String getSession()
Returns the javax.mail.Session object.

Returns:
The javax.mail.Session object

setSession

public void setSession(String session)
Sets the JNDI lookup for a javax.mail.Session object to be used as the mail Session.

Parameters:
session - Name of the JNDI lookup

getSubject

public String getSubject()
Returns the subject of the message.

Returns:
The subject

setSubject

public void setSubject(String subject)
Sets the subject for this message.

Parameters:
subject - The subject for this message

getTo

public String getTo()
Returns the to attribute.

Returns:
The to attribute

setTo

public void setTo(String to)
Sets the "to" recipients for this message.

Parameters:
to - The e-mail address for this recipient

getUsername

public String getUsername()
Returns the username for SMTP authentication.

Returns:
The username

setUsername

public void setUsername(String username)
Set the login username name for PLAIN or LOGIN SMTP authentication.

Parameters:
username - The username

getVar

public String getVar()
Returns the name of the variable to store the message in.

Returns:
The name of the variable

setVar

public void setVar(String var)
Sets the var attribute. This is the name used to store the message in the scope set by setScope(java.lang.String).

Parameters:
var - The name of the variable

isBackground

public boolean isBackground()
Returns whether the mail should be sent in the background.

Returns:
True if background, false otherwise

setBackground

public void setBackground(boolean background)
Sets the background attribute.

Parameters:
background - True when the message will be sent in a separate thread


Copyright © 2004 Apache Software Foundation, http://jakarta.apache.org/taglibs