catlett 01/04/20 11:44:44
Modified: mailer/src/org/apache/taglibs/mailer MailTag.java
Log:
updated to run cleaner implementation of MimePartDataSource
Revision Changes Path
1.2 +41 -49
jakarta-taglibs/mailer/src/org/apache/taglibs/mailer/MailTag.java
Index: MailTag.java
===================================================================
RCS file:
/home/cvs/jakarta-taglibs/mailer/src/org/apache/taglibs/mailer/MailTag.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- MailTag.java 2001/03/31 03:10:36 1.1
+++ MailTag.java 2001/04/20 18:44:38 1.2
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-taglibs/mailer/src/org/apache/taglibs/mailer/MailTag.java,v 1.1
2001/03/31 03:10:36 glenn Exp $
- * $Revision: 1.1 $
- * $Date: 2001/03/31 03:10:36 $
+ * $Header:
/home/cvs/jakarta-taglibs/mailer/src/org/apache/taglibs/mailer/MailTag.java,v 1.2
2001/04/20 18:44:38 catlett Exp $
+ * $Revision: 1.2 $
+ * $Date: 2001/04/20 18:44:38 $
*
* ====================================================================
*
@@ -211,60 +211,52 @@
*/
public final int doStartTag() throws JspException {
- try {
-
- if (mimemessage != null) {
- try {
- // get initial context from which to lookup messagedatasource
- Context ctx = new InitialContext();
-
- // create mail message using preexisting jndi named message
- MimePartDataSource mds =
- (MimePartDataSource)ctx.lookup(mimemessage);
- message = new MimeMessage(
- (MimeMessage)mds.getMessageContext().getMessage());
- sessionobj = (Session)mds.getMessageContext().getSession();
- } catch (NamingException ne) {
- throw new JspException("Naming Exception " +
- ne.getExplanation());
- }
- } else if (session != null) {
- try {
- // get initial context from which to lookup session
- Context ctx = new InitialContext();
-
- // create the mail message using the preconfigured jndi
- // named session
- sessionobj = (Session)ctx.lookup(session);
- message = new MimeMessage(sessionobj);
- } catch (NamingException ne) {
- throw new JspException("Naming Exception " +
+ if (mimemessage != null) {
+ try {
+ // get initial context from which to lookup messagedatasource
+ Context ctx = new InitialContext();
+
+ // create mail message using preexisting jndi named message
+ MimePartDataSource mds =
+ (MimePartDataSource)ctx.lookup(mimemessage);
+ sessionobj = (Session)mds.getMessageContext().getSession();
+ message = new MimeMessage(sessionobj);
+ } catch (NamingException ne) {
+ throw new JspException("Naming Exception " +
+ ne.getExplanation());
+ }
+ } else if (session != null) {
+ try {
+ // get initial context from which to lookup session
+ Context ctx = new InitialContext();
+
+ // create the mail message using the preconfigured jndi
+ // named session
+ sessionobj = (Session)ctx.lookup(session);
+ message = new MimeMessage(sessionobj);
+ } catch (NamingException ne) {
+ throw new JspException("Naming Exception " +
ne.getExplanation());
- }
- } else {
- // if configuring one of the above objects the following list
- // are a good set to use to take care of error handling if some
- // addresses are not valid
-
- // set up the smtp session that will send the message
- Properties props = new Properties();
- // set host to server
- props.put("mail.smtp.host", server);
- // set properties to deal will SendFailedExceptions
- // send to all legal addresses
- props.put("mail.smtp.sendpartial", "true");
- // set notification
- props.put("mail.smtp.dsn.notify", "FAILURE");
- // set amount of message to get returned
- props.put("mail.smtp.dsn.ret", "FULL");
- // create new piece of mail for the smtp mail session
- sessionobj = Session.getDefaultInstance(props, null);
- message = new MimeMessage(sessionobj);
}
-
- } catch (MessagingException me) {
- throw new JspException("An error occured creating the email message "
- + me.getMessage());
+ } else {
+ // if configuring one of the above objects the following list
+ // are a good set to use to take care of error handling if some
+ // addresses are not valid
+
+ // set up the smtp session that will send the message
+ Properties props = new Properties();
+ // set host to server
+ props.put("mail.smtp.host", server);
+ // set properties to deal will SendFailedExceptions
+ // send to all legal addresses
+ props.put("mail.smtp.sendpartial", "true");
+ // set notification
+ props.put("mail.smtp.dsn.notify", "FAILURE");
+ // set amount of message to get returned
+ props.put("mail.smtp.dsn.ret", "FULL");
+ // create new piece of mail for the smtp mail session
+ sessionobj = Session.getDefaultInstance(props, null);
+ message = new MimeMessage(sessionobj);
}
return EVAL_BODY_TAG; // evaluate the body of this tag