jakarta-taglibs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From felip...@apache.org
Subject cvs commit: jakarta-taglibs-sandbox/mailer2/xml mailer2.xml
Date Sat, 14 Aug 2004 12:24:37 GMT
felipeal    2004/08/14 05:24:37

  Modified:    mailer2  build.xml
               mailer2/examples/web authenticate.jsp digest.jsp encrypt.jsp
                        header.jsp html.jsp index.jsp load.jsp
                        multipart.jsp replyto.jsp send.jsp sign.jsp
                        simple.jsp
               mailer2/src/org/apache/taglibs/mailer2 AddRecipientTag.java
                        AttachTag.java EncryptTag.java MailTag.java
                        PartTag.java ReplyToTag.java SignTag.java
                        Validator.java
               mailer2/xml mailer2.xml
  Log:
  bundle of changes sent by Jeroen:
  - Fixed the documentation, TLD, source code style (missorted modifiers andequals() comparisons with a string literal)
  - Use ArrayList instead of Vector- Fixed some error messages
  - Fixed the mt:addrecipient tag to actually add a recipient
  - Fixed the mt:encrypt tag to actually encrypt the content instead of onlysending an empty message
  - Fixed an NPE in the MailTag if no from is given
  - Return Session.getInstance() instead of Session.getDefaultInstance() tocreate a new javax.mail.Session, because of problems with SMTPauthentication. Still not completely solved, though. Comments are welcome.
  - Enhanced the use of the mt:sign and mt:encrypt tags to use the serverand/or port given as attributes in the mt:mail tag or as context-params soan signed and/or encrypted message no longer use the default SMTP server andport (localhost:25). The values of these attributes are stored in thePageContext in PAGE scope
  - Updated the examples to become XHTML 1.0 Strict instead of HTML 4.01Strict
  
  Revision  Changes    Path
  1.2       +0 -2      jakarta-taglibs-sandbox/mailer2/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs-sandbox/mailer2/build.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- build.xml	28 Jul 2004 02:22:15 -0000	1.1
  +++ build.xml	14 Aug 2004 12:24:34 -0000	1.2
  @@ -26,10 +26,8 @@
       <copy todir="${build.examples}/WEB-INF/lib" file="${jstl.jar}"/>
       <copy todir="${build.examples}/WEB-INF/lib" file="${activation.jar}"/>
       <copy todir="${build.examples}/WEB-INF/lib" file="${mail.jar}"/>
  -<!-- uncomment these lines to distribute BC jars
       <copy todir="${build.examples}/WEB-INF/lib" file="${bcmail.jar}"/>
       <copy todir="${build.examples}/WEB-INF/lib" file="${bcprov.jar}"/>
  --->
     </target>
   
     <target name="checkRequirements.pre">
  
  
  
  1.2       +14 -7     jakarta-taglibs-sandbox/mailer2/examples/web/authenticate.jsp
  
  Index: authenticate.jsp
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs-sandbox/mailer2/examples/web/authenticate.jsp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- authenticate.jsp	28 Jul 2004 02:22:15 -0000	1.1
  +++ authenticate.jsp	14 Aug 2004 12:24:34 -0000	1.2
  @@ -1,4 +1,4 @@
  -<!doctype HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  +<!doctype html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
   
   <%@ taglib prefix="mt" uri="http://jakarta.apache.org/taglibs/mailer2" %>
   <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
  @@ -7,6 +7,8 @@
   <head>
   <title>smtp authentication</title>
   <link rel="stylesheet" type="text/css" href="mailer2.css"/>
  +<link rel="home" href="index.jsp"/>
  +<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
   </head>
   
   <body>
  @@ -23,24 +25,29 @@
           Sent with SMTP authentication
       </mt:mail>
   
  -    Mail sent to ${param.email}
  +    <p>Mail sent to ${param.email}</p>
   </c:if>
   
   <form method="post" action="#">
  +	<p>
       E-mail address to send example to:<br/>
       <input type="name" name="email" value="${sessionScope.email}" size="30"/>
  -    <p/>
  +    </p>
  +	<p>
       SMTP server that requires PLAIN/LOGIN SMTP authentication:<br/>
       <input type="server" name="server" value="${sessionScope.server}" size="30"/>
  -    <p/>
  +    </p>
  +	<p>
       SMTP username:<br/>
       <input type="name" name="username" value="${sessionScope.username}" size="30"/>
  -    <p/>
  +    </p>
  +	<p>
       SMTP password:<br/>
       <input type="password" name="password" value="${sessionScope.password}" size="30"/>
  -    <p/>
  -    <br/>
  +    </p>
  +	<p>
       <input class="button" type="submit" value="Send"/>
  +    </p>
   </form>
   
   <p>
  
  
  
  1.2       +13 -7     jakarta-taglibs-sandbox/mailer2/examples/web/digest.jsp
  
  Index: digest.jsp
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs-sandbox/mailer2/examples/web/digest.jsp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- digest.jsp	28 Jul 2004 02:22:15 -0000	1.1
  +++ digest.jsp	14 Aug 2004 12:24:35 -0000	1.2
  @@ -1,4 +1,4 @@
  -<!doctype HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  +<!doctype html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
   
   <%@ taglib prefix="mt" uri="http://jakarta.apache.org/taglibs/mailer2" %>
   <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
  @@ -7,6 +7,8 @@
   <head>
   <title>digest mail example</title>
   <link rel="stylesheet" type="text/css" href="mailer2.css"/>
  +<link rel="home" href="index.jsp"/>
  +<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
   </head>
   
   <body>
  @@ -17,30 +19,34 @@
       <c:set var="server" value="${param.server}" scope="session"/>
       <mt:mail var="a1" from="john.doe@example.com" subject="First Mail">
           <mt:addrecipient type="to">${param.email}</mt:addrecipient>
  -        First mail
  +        First mail in digest
       </mt:mail>
       <mt:mail var="a2" from="jane.doe@example.com" subject="Second Mail">
           <mt:addrecipient type="to">${param.email}</mt:addrecipient>
  -        Second mail
  +        Second mail in digest
       </mt:mail>
  -    <mt:mail from="${param.to}" subject="digest mail example" type="multipart/digest" server="${param.server}" background="false">
  +    <mt:mail from="${param.email}" subject="digest mail example" type="multipart/digest" server="${param.server}" background="false">
           <mt:addrecipient type="to" name="Digest User">${param.email}</mt:addrecipient>
           This digest contains two messages.
           <mt:attach message="${a1}"/>
           <mt:attach message="${a2}"/>
       </mt:mail>
   
  -    Mail sent to ${param.email}
  +    <p>Mail sent to ${param.email}</p>
   </c:if>
   
   <form method="post" action="#" enctype="multipart/form-data">
  +	<p>
       E-mail address to send example to:<br/>
       <input type="name" name="email" value="${sessionScope.email}" size="30"/>
  -    <p/>
  +    </p>
  +	<p>
       SMTP server (in your local network):<br/>
       <input type="server" name="server" value="${sessionScope.server}" size="30"/>
  -    <br/>
  +    </p>
  +    <p>
       <input class="button" type="submit" value="Send"/>
  +    </p>
   </form>
   
   <p>
  
  
  
  1.2       +18 -9     jakarta-taglibs-sandbox/mailer2/examples/web/encrypt.jsp
  
  Index: encrypt.jsp
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs-sandbox/mailer2/examples/web/encrypt.jsp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- encrypt.jsp	28 Jul 2004 02:22:15 -0000	1.1
  +++ encrypt.jsp	14 Aug 2004 12:24:35 -0000	1.2
  @@ -1,4 +1,4 @@
  -<!doctype HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  +<!doctype html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
   
   <%@ taglib prefix="mt" uri="http://jakarta.apache.org/taglibs/mailer2" %>
   <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
  @@ -7,6 +7,8 @@
   <head>
   <title>sign and encrypt message</title>
   <link rel="stylesheet" type="text/css" href="mailer2.css"/>
  +<link rel="home" href="index.jsp"/>
  +<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
   </head>
   
   <body>
  @@ -30,7 +32,7 @@
           This mail message has been <b>signed</b> with a <a href="http://www.thawte.com/email">Thawte Freemail certificate</a>.
           </p>
           <p>
  -        Secondly, it has been encrypted.
  +        Secondly, it has been <b>encrypted</b>.
           </p>
           <p>
           Therefore you know and you can verify that the message has not been tampered with since it has been sent.
  @@ -41,29 +43,36 @@
           </html >
       </mt:mail>
       <mt:encrypt message="${message}" var="encryptedMessage" keystore="${param.keystore}" alias="${param.alias}" storepass="${param.storepass}"/>
  -    <mt:save message="${encryptedMessage}" file="encrypted.message"/>
  +    <mt:save message="${encryptedMessage}" filename="encrypted.message"/>
       <mt:send message="${encryptedMessage}" background="false"/>
   
       <p>Mail sent to ${param.email}</p>
   </c:if>
   
  -<form method="post" action="#">
  +<form method="post" action="#" encoding="multipart/form-data">
  +	<p>
       E-mail address to send example to:<br/>
       <input type="name" name="email" value="${sessionScope.email}" size="30"/>
  -    <p/>
  +    </p>
  +	<p>
       SMTP server:<br/>
       <input type="server" name="server" value="${sessionScope.server}" size="30"/>
  -    <p/>
  +    </p>
  +	<p>
       PKCS12 keystore file (*.p12, *.pfx):<br/>
       <input type="file" name="keystore" size="30"/>
  -    <p/>
  +    </p>
  +	<p>
       Keystore password:<br/>
       <input type="password" name="storepass" value="${sessionScope.storepass}" size="30"/>
  -    <p/>
  +    </p>
  +	<p>
       Private key alias:<br/>
       <input type="text" name="alias" value="${sessionScope.alias}" size="30"/>
  -    <p/>
  +    </p>
  +	<p>
       <input class="button" type="submit" value="Send"/>
  +    </p>
   </form>
   
   <p><a href="index.jsp">Back</a></p>
  
  
  
  1.2       +10 -4     jakarta-taglibs-sandbox/mailer2/examples/web/header.jsp
  
  Index: header.jsp
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs-sandbox/mailer2/examples/web/header.jsp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- header.jsp	28 Jul 2004 02:22:15 -0000	1.1
  +++ header.jsp	14 Aug 2004 12:24:35 -0000	1.2
  @@ -1,4 +1,4 @@
  -<!doctype HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  +<!doctype html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
   
   <%@ taglib prefix="mt" uri="http://jakarta.apache.org/taglibs/mailer2" %>
   <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
  @@ -7,6 +7,8 @@
   <head>
   <title>header mail example</title>
   <link rel="stylesheet" type="text/css" href="mailer2.css"/>
  +<link rel="home" href="index.jsp"/>
  +<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
   </head>
   
   <body>
  @@ -25,17 +27,21 @@
   An example e-mail with additional headers.
       </mt:mail>
   
  -    Mail sent to ${param.email}
  +    <p>Mail sent to ${param.email}</p>
   </c:if>
   
   <form method="post" action="#" enctype="multipart/form-data">
  +	<p>
       E-mail address to send example to:<br/>
       <input type="name" name="email" value="${sessionScope.email}" size="30"/>
  -    <p/>
  +    </p>
  +	<p>
       SMTP server (in your local network):<br/>
       <input type="server" name="server" value="${sessionScope.server}" size="30"/>
  -    <br/>
  +    </p>
  +    <p>
       <input class="button" type="submit" value="Send"/>
  +    </p>
   </form>
   
   <p>
  
  
  
  1.2       +10 -4     jakarta-taglibs-sandbox/mailer2/examples/web/html.jsp
  
  Index: html.jsp
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs-sandbox/mailer2/examples/web/html.jsp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- html.jsp	28 Jul 2004 02:22:15 -0000	1.1
  +++ html.jsp	14 Aug 2004 12:24:35 -0000	1.2
  @@ -1,4 +1,4 @@
  -<!doctype HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  +<!doctype html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
   
   <%@ taglib prefix="mt" uri="http://jakarta.apache.org/taglibs/mailer2" %>
   <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
  @@ -7,6 +7,8 @@
   <head>
   <title>html only example</title>
   <link rel="stylesheet" type="text/css" href="mailer2.css"/>
  +<link rel="home" href="index.jsp"/>
  +<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
   </head>
   
   <body>
  @@ -39,17 +41,21 @@
           </html >
       </mt:mail>
   
  -    Mail sent to ${param.email}
  +    <p>Mail sent to ${param.email}</p>
   </c:if>
   
   <form method="post" action="#" enctype="multipart/form-data">
  +    <p>
       E-mail address to send example to:<br/>
       <input type="name" name="email" value="${sessionScope.email}" size="30"/>
  -    <p/>
  +    </p>
  +	<p>
       SMTP server (in your local network):<br/>
       <input type="server" name="server" value="${sessionScope.server}" size="30"/>
  -    <br/>
  +    </p>
  +    <p>
       <input class="button" type="submit" value="Send"/>
  +    </p>
   </form>
   
   <p>
  
  
  
  1.2       +7 -1      jakarta-taglibs-sandbox/mailer2/examples/web/index.jsp
  
  Index: index.jsp
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs-sandbox/mailer2/examples/web/index.jsp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- index.jsp	28 Jul 2004 02:22:15 -0000	1.1
  +++ index.jsp	14 Aug 2004 12:24:35 -0000	1.2
  @@ -1,9 +1,11 @@
  -<!doctype HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  +<!doctype html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
   
   <html>
   <head>
   <title>mailer2 taglib examples</title>
   <link rel="stylesheet" type="text/css" href="mailer2.css"/>
  +<link rel="home" href="index.jsp"/>
  +<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
   </head>
   
   <body>
  @@ -25,5 +27,9 @@
   <li><a href="encrypt.jsp">encrypt</a></li>
   </ul>
   
  +<ul>
  +<li><a href="load.jsp">loading</a> a <a href="sign.jsp">previously stored</a> message</li>
  +</ul>
  +
   </body>
   </html>
  
  
  
  1.2       +5 -3      jakarta-taglibs-sandbox/mailer2/examples/web/load.jsp
  
  Index: load.jsp
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs-sandbox/mailer2/examples/web/load.jsp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- load.jsp	28 Jul 2004 02:22:15 -0000	1.1
  +++ load.jsp	14 Aug 2004 12:24:35 -0000	1.2
  @@ -1,4 +1,4 @@
  -<!doctype HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  +<!doctype html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
   
   <%@ taglib prefix="mt" uri="http://jakarta.apache.org/taglibs/mailer2" %>
   <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
  @@ -7,6 +7,8 @@
   <head>
   <title>load message</title>
   <link rel="stylesheet" type="text/css" href="mailer2.css"/>
  +<link rel="home" href="index.jsp"/>
  +<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
   </head>
   
   <body>
  @@ -17,10 +19,10 @@
   </c:catch>
   <c:choose>
       <c:when test="${empty ex}">
  -        <mt:load var="message" file="signed.message"/>
  +        <mt:load var="message" filename="signed.message"/>
           <mt:send message="${message}"/>
   
  -        <p>Previously signed and save message loaded and sent</p>
  +        <p>Previously signed and saved message loaded and sent</p>
       </c:when>
       <c:otherwise>
           <div class="red">
  
  
  
  1.2       +10 -4     jakarta-taglibs-sandbox/mailer2/examples/web/multipart.jsp
  
  Index: multipart.jsp
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs-sandbox/mailer2/examples/web/multipart.jsp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- multipart.jsp	28 Jul 2004 02:22:15 -0000	1.1
  +++ multipart.jsp	14 Aug 2004 12:24:35 -0000	1.2
  @@ -1,4 +1,4 @@
  -<!doctype HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  +<!doctype html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
   
   <%@ taglib prefix="mt" uri="http://jakarta.apache.org/taglibs/mailer2" %>
   <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
  @@ -7,6 +7,8 @@
   <head>
   <title>multipart mail example</title>
   <link rel="stylesheet" type="text/css" href="mailer2.css"/>
  +<link rel="home" href="index.jsp"/>
  +<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
   </head>
   
   <body>
  @@ -40,17 +42,21 @@
           </mt:part>
       </mt:mail>
   
  -    Mail sent to ${param.email}
  +    <p>Mail sent to ${param.email}</p>
   </c:if>
   
   <form method="post" action="#" enctype="multipart/form-data">
  +    <p>
       E-mail address to send example to:<br/>
       <input type="name" name="email" value="${sessionScope.email}" size="30"/>
  -    <p/>
  +    </p>
  +	<p>
       SMTP server (in your local network):<br/>
       <input type="server" name="server" value="${sessionScope.server}" size="30"/>
  -    <br/>
  +    </p>
  +    <p>
       <input class="button" type="submit" value="Send"/>
  +    </p>
   </form>
   
   <p>
  
  
  
  1.2       +11 -5     jakarta-taglibs-sandbox/mailer2/examples/web/replyto.jsp
  
  Index: replyto.jsp
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs-sandbox/mailer2/examples/web/replyto.jsp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- replyto.jsp	28 Jul 2004 02:22:15 -0000	1.1
  +++ replyto.jsp	14 Aug 2004 12:24:35 -0000	1.2
  @@ -1,4 +1,4 @@
  -<!doctype HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  +<!doctype html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
   
   <%@ taglib prefix="mt" uri="http://jakarta.apache.org/taglibs/mailer2" %>
   <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
  @@ -7,6 +7,8 @@
   <head>
   <title>reply-to mail example</title>
   <link rel="stylesheet" type="text/css" href="mailer2.css"/>
  +<link rel="home" href="index.jsp"/>
  +<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
   </head>
   
   <body>
  @@ -25,17 +27,21 @@
   An example e-mail with reply-to set.
       </mt:mail>
   
  -    Mail sent to ${param.email}
  +    <p>Mail sent to ${param.email}</p>
   </c:if>
   
  -<form method="post" action="#" enctype="multipart/form-data">
  +<form method="post" action="#">
  +	<p>
       E-mail address to send example to:<br/>
       <input type="name" name="email" value="${sessionScope.email}" size="30"/>
  -    <p/>
  +    </p>
  +	<p>
       SMTP server (in your local network):<br/>
       <input type="server" name="server" value="${sessionScope.server}" size="30"/>
  -    <br/>
  +    </p>
  +    <p>
       <input class="button" type="submit" value="Send"/>
  +    </p>
   </form>
   
   <p>
  
  
  
  1.2       +11 -5     jakarta-taglibs-sandbox/mailer2/examples/web/send.jsp
  
  Index: send.jsp
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs-sandbox/mailer2/examples/web/send.jsp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- send.jsp	28 Jul 2004 02:22:15 -0000	1.1
  +++ send.jsp	14 Aug 2004 12:24:35 -0000	1.2
  @@ -1,4 +1,4 @@
  -<!doctype HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  +<!doctype html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
   
   <%@ taglib prefix="mt" uri="http://jakarta.apache.org/taglibs/mailer2" %>
   <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
  @@ -7,6 +7,8 @@
   <head>
   <title>simple mail example using mt:send</title>
   <link rel="stylesheet" type="text/css" href="mailer2.css"/>
  +<link rel="home" href="index.jsp"/>
  +<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
   </head>
   
   <body>
  @@ -24,17 +26,21 @@
       </mt:mail>
       <mt:send message="${message}"/>
   
  -    Mail sent to ${param.email}
  +    <p>Mail sent to ${param.email}</p>
   </c:if>
   
  -<form method="post" action="#" enctype="multipart/form-data">
  +<form method="post" action="#">
  +	<p>
       E-mail address to send example to:<br/>
       <input type="name" name="email" value="${sessionScope.email}" size="30"/>
  -    <p/>
  +    </p>
  +	<p>
       SMTP server (in your local network):<br/>
       <input type="server" name="server" value="${sessionScope.server}" size="30"/>
  -    <br/>
  +    </p>
  +    <p>
       <input class="button" type="submit" value="Send"/>
  +    </p>
   </form>
   
   <p>
  
  
  
  1.2       +18 -9     jakarta-taglibs-sandbox/mailer2/examples/web/sign.jsp
  
  Index: sign.jsp
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs-sandbox/mailer2/examples/web/sign.jsp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- sign.jsp	28 Jul 2004 02:22:15 -0000	1.1
  +++ sign.jsp	14 Aug 2004 12:24:35 -0000	1.2
  @@ -1,4 +1,4 @@
  -<!doctype HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  +<!doctype html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
   
   <%@ taglib prefix="mt" uri="http://jakarta.apache.org/taglibs/mailer2" %>
   <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
  @@ -7,6 +7,8 @@
   <head>
   <title>sign message</title>
   <link rel="stylesheet" type="text/css" href="mailer2.css"/>
  +<link rel="home" href="index.jsp"/>
  +<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
   </head>
   
   <body>
  @@ -27,7 +29,7 @@
           </head>
           <body>
           <p>
  -        This mail message has been <b>signed</b> with a <a href="http://www.thawte.com/email">Thawte Freemail certificate</a>.
  +        This mail message has been <b>signed</b> with a certificate.
           </p>
           <p>
           Therefore you know and you can verify that the message has not been tampered with since it has been sent.
  @@ -38,29 +40,36 @@
           </html >
       </mt:mail>
       <mt:sign message="${message}" var="signedMessage" keystore="${param.keystore}" alias="${param.alias}" storepass="${param.storepass}"/>
  -    <mt:save message="${signedMessage}" file="signed.message"/>
  +    <mt:save message="${signedMessage}" filename="signed.message"/>
       <mt:send message="${signedMessage}" background="false"/>
   
       <p>Mail sent to ${param.email}</p>
   </c:if>
   
  -<form method="post" action="#">
  +<form method="post" action="#" enctype="multipart/formdata">
  +	<p>
       E-mail address to send example to:<br/>
       <input type="name" name="email" value="${sessionScope.email}" size="30"/>
  -    <p/>
  +    </p>
  +	<p>
       SMTP server:<br/>
       <input type="server" name="server" value="${sessionScope.server}" size="30"/>
  -    <p/>
  +    </p>
  +	<p>
       PKCS12 keystore file (*.p12, *.pfx):<br/>
       <input type="file" name="keystore" size="30"/>
  -    <p/>
  +    </p>
  +	<p>
       Keystore password:<br/>
       <input type="password" name="storepass" value="${sessionScope.storepass}" size="30"/>
  -    <p/>
  +    </p>
  +	<p>
       Private key alias:<br/>
       <input type="text" name="alias" value="${sessionScope.alias}" size="30"/>
  -    <p/>
  +    </p>
  +	<p>
       <input class="button" type="submit" value="Send"/>
  +    </p>
   </form>
   
   <p><a href="index.jsp">Back</a></p>
  
  
  
  1.2       +13 -7     jakarta-taglibs-sandbox/mailer2/examples/web/simple.jsp
  
  Index: simple.jsp
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs-sandbox/mailer2/examples/web/simple.jsp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- simple.jsp	28 Jul 2004 02:22:15 -0000	1.1
  +++ simple.jsp	14 Aug 2004 12:24:35 -0000	1.2
  @@ -1,4 +1,4 @@
  -<!doctype HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  +<!doctype html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
   
   <%@ taglib prefix="mt" uri="http://jakarta.apache.org/taglibs/mailer2" %>
   <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
  @@ -7,6 +7,8 @@
   <head>
   <title>simple mail example</title>
   <link rel="stylesheet" type="text/css" href="mailer2.css"/>
  +<link rel="home" href="index.jsp"/>
  +<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
   </head>
   
   <body>
  @@ -16,25 +18,29 @@
   <c:if test="${not empty param.email and not empty param.server}">
       <c:set var="email" value="${param.email}" scope="session"/>
       <c:set var="server" value="${param.server}" scope="session"/>
  -    <mt:mail from="${param.email}" subject="simple mail example" importance="low" server="${param.server}" background="false">
  -        <mt:addrecipient type="to" name="Test User">${param.email}</mt:addrecipient>
  +    <mt:mail from="${param.email}" to="${param.email}" subject="simple mail example" importance="low" server="${param.server}" background="false">
  +        <mt:addrecipient type="cc" name="Test User in CC">${param.email}</mt:addrecipient>
   Hello, World
   
   An example e-mail with a single attachment.
           <mt:attach url="http://jakarta.apache.org/images/jakarta-logo.gif"/>
       </mt:mail>
   
  -    Mail sent to ${param.email}
  +    <p>Mail sent to ${param.email}</p>
   </c:if>
   
  -<form method="post" action="#" enctype="multipart/form-data">
  +<form method="post" action="#">
  +	<p>
       E-mail address to send example to:<br/>
       <input type="name" name="email" value="${sessionScope.email}" size="30"/>
  -    <p/>
  +    </p>
  +	<p>
       SMTP server (in your local network):<br/>
       <input type="server" name="server" value="${sessionScope.server}" size="30"/>
  -    <br/>
  +    </p>
  +    <p>
       <input class="button" type="submit" value="Send"/>
  +    </p>
   </form>
   
   <p>
  
  
  
  1.2       +37 -12    jakarta-taglibs-sandbox/mailer2/src/org/apache/taglibs/mailer2/AddRecipientTag.java
  
  Index: AddRecipientTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs-sandbox/mailer2/src/org/apache/taglibs/mailer2/AddRecipientTag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AddRecipientTag.java	28 Jul 2004 02:22:15 -0000	1.1
  +++ AddRecipientTag.java	14 Aug 2004 12:24:36 -0000	1.2
  @@ -44,26 +44,35 @@
        * Default zero-arg constructor.
        */
       public AddRecipientTag() {
  -        tagName = "mt:addrecipient";
       }
   
  -    /**
  -     * Add a recipient of a particular type to the parent of this tag.
  -     * @param address The e-mail address
  -     * @param name The real name
  -     * @throws JspException Upon error
  -     */
  -    public void addRecipient(String address, String name) throws JspException {
  +    public int doEndTag() throws JspException {
           MailTag mailTag = (MailTag) findAncestorWithClass(this, MailTag.class);
   
           if (mailTag != null) {
  +            String localAddress = getAddress();
  +            if (localAddress == null) {
  +                localAddress = getBody();
  +            }
  +            if (localAddress == null) {
  +                throw new JspException("mt:addrecipient: no recipient specified in address attribute or body content");
  +            }
  +
  +            String localName = getName();
  +            if (localName == null) {
  +                localName = localAddress;
  +            }
  +
               try {
  -                mailTag.addRecipient(getType(),
  -                    new InternetAddress(address, name));
  +                mailTag.addRecipient(getType(), new InternetAddress(localAddress, localName));
               } catch (UnsupportedEncodingException ex) {
                   /* Ignore */
               }
  +        } else {
  +            throw new JspException("mt:replyto should be child of mt:mail");
           }
  +
  +        return SKIP_BODY;
       }
   
       public void release() {
  @@ -95,21 +104,37 @@
        * @return The e-mail address
        *
        * @jsp.attribute name="address" required="false" rtexprvalue="true"
  -     *      description="The e-mail address of the recipient to add"
  +     *      description="The e-mail address to reply-to"
        */
       public String getAddress() {
           return super.getAddress();
       }
   
       /**
  +     * Sets the e-mail address.
  +     * @param address The e-mail address
  +     */
  +    public void setAddress(String address) {
  +        super.setAddress(address);
  +    }
  +
  +    /**
        * Returns the real name.
        * @return The real name
        *
        * @jsp.attribute name="name" required="false" rtexprvalue="true"
  -     *      description="The real name of the recipient to add"
  +     *      description="The real name of the reply-to recipient"
        */
       public String getName() {
           return super.getName();
       }
  +
  +    /**
  +     * Sets the real name of the recipient.
  +     * @param name The real name
  +     */
  +    public void setName(String name) {
  +        super.setName(name);
  +    }
   }
   
  
  
  
  1.2       +1 -1      jakarta-taglibs-sandbox/mailer2/src/org/apache/taglibs/mailer2/AttachTag.java
  
  Index: AttachTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs-sandbox/mailer2/src/org/apache/taglibs/mailer2/AttachTag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AttachTag.java	28 Jul 2004 02:22:15 -0000	1.1
  +++ AttachTag.java	14 Aug 2004 12:24:36 -0000	1.2
  @@ -204,7 +204,7 @@
               log.info("Attaching " + localName + " to mail");
               ((MailTag) parent).addPart(mbp);
           } else {
  -            throw new JspException("mt:attach: not a child of mt:mail or mt:part");
  +            throw new JspException("mt:attach: should be a child of mt:mail or mt:part");
           }
   
           return EVAL_PAGE;
  
  
  
  1.2       +17 -2     jakarta-taglibs-sandbox/mailer2/src/org/apache/taglibs/mailer2/EncryptTag.java
  
  Index: EncryptTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs-sandbox/mailer2/src/org/apache/taglibs/mailer2/EncryptTag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- EncryptTag.java	28 Jul 2004 02:22:15 -0000	1.1
  +++ EncryptTag.java	14 Aug 2004 12:24:36 -0000	1.2
  @@ -18,13 +18,19 @@
   
   import java.security.KeyStore;
   import java.security.PrivateKey;
  +import java.security.NoSuchProviderException;
  +import java.security.NoSuchAlgorithmException;
  +import java.security.GeneralSecurityException;
   import java.security.cert.X509Certificate;
   import java.util.Enumeration;
   import java.io.ByteArrayOutputStream;
  +import java.io.IOException;
  +import java.io.ByteArrayInputStream;
   
   import javax.mail.internet.MimeBodyPart;
   import javax.mail.internet.MimeMessage;
   import javax.mail.Session;
  +import javax.mail.MessagingException;
   import javax.servlet.jsp.JspException;
   
   import org.bouncycastle.mail.smime.SMIMEEnvelopedGenerator;
  @@ -79,7 +85,8 @@
               ByteArrayOutputStream out = new ByteArrayOutputStream();
               encryptedPart.writeTo(out);
   
  -            MimeMessage encryptedMessage = new MimeMessage(Session.getInstance(MailTag.getSessionProperties(pageContext, (String) null, 0)));
  +            MimeMessage encryptedMessage = new MimeMessage(Session.getInstance(MailTag.getSessionProperties(pageContext, (String) null, 0)),
  +                   new ByteArrayInputStream(out.toByteArray()));
   
               /* Set all original MIME headers in the encrypted message */
               Enumeration headers = getMessage().getAllHeaderLines();
  @@ -95,7 +102,15 @@
               pageContext.setAttribute(getVar(), encryptedMessage, MailTag.getScopeType(getScope()));
           } catch (SMIMEException ex) {
               throw new JspException(ex.getUnderlyingException());
  -        } catch (Exception ex) {
  +        } catch (MessagingException ex) {
  +            throw new JspException(ex);
  +        } catch (NoSuchProviderException ex) {
  +            throw new JspException(ex);
  +        } catch (NoSuchAlgorithmException ex) {
  +            throw new JspException(ex);
  +        } catch (GeneralSecurityException ex) {
  +            throw new JspException(ex);
  +        } catch (IOException ex) {
               throw new JspException(ex);
           }
   
  
  
  
  1.2       +35 -6     jakarta-taglibs-sandbox/mailer2/src/org/apache/taglibs/mailer2/MailTag.java
  
  Index: MailTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs-sandbox/mailer2/src/org/apache/taglibs/mailer2/MailTag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MailTag.java	28 Jul 2004 02:22:15 -0000	1.1
  +++ MailTag.java	14 Aug 2004 12:24:36 -0000	1.2
  @@ -239,7 +239,9 @@
               if (localFrom == null) {
                   localFrom = pageContext.getServletContext().getInitParameter(FROM);
               }
  +            if (localFrom != null) {
               message.setFrom(new InternetAddress(localFrom));
  +			}
   
               /* Add the recipients given in the to, cc and bcc attributes */
               if (getTo() != null) {
  @@ -295,11 +297,11 @@
               /* Set importance headers */
               if (getImportance() != null) {
                   /* Add additional Microsoft'isms to prevent spam scanners to report this mail as spam */
  -                if (getImportance().equals("high")) {
  +                if ("high".equals(getImportance())) {
                       message.addHeader("X-Priority", "1");
  -                } else if (getImportance().equals("normal")) {
  +                } else if ("normail".equals(getImportance())) {
                       message.addHeader("X-Priority", "3");
  -                } else if (getImportance().equals("low")) {
  +                } else if ("low".equals(getImportance())) {
                       message.addHeader("X-Priority", "5");
                   }
                   message.addHeader("Importance", getImportance());
  @@ -394,7 +396,7 @@
        * @return The scopeType as found in PageContext
        * @throws JspException For an invalid scope
        */
  -    static public int getScopeType(String scope) throws JspException {
  +    public static int getScopeType(String scope) throws JspException {
           int scopeType;
           if ("request".equals(scope)) {
               scopeType = PageContext.REQUEST_SCOPE;
  @@ -458,7 +460,8 @@
                       props.put("mail.smtp.auth", "true");
                       authenticator = new MailAuthenticator(localUser, localPassword);
                   }
  -                sessionobj = Session.getDefaultInstance(props, authenticator);
  +
  +                sessionobj = Session.getInstance(props, authenticator);
               }
           } catch (NamingException ex) {
               throw new JspException("mt:mail: NamingException " + ex.getExplanation());
  @@ -474,6 +477,9 @@
           /* Set SMTP server name */
           String localServer = server;
           if (localServer == null) {
  +            localServer = (String) pageContext.findAttribute(SERVER);
  +        }
  +        if (localServer == null) {
               localServer = pageContext.getServletContext().getInitParameter(SERVER);
           }
           if (localServer == null) {
  @@ -481,10 +487,25 @@
           }
           props.put("mail.smtp.host", localServer);
   
  +        /**
  +         * Store the server name in page scope, so additional sign and/or encrypt
  +         * tags access the same SMTP server and port, as these tags have to create a
  +         * new MimeMessage(Session) object without having access to MailTag's
  +         * server and/or port attributes.
  +         */
  +        pageContext.setAttribute(SERVER, localServer);
  +
           /* Set SMTP server port */
           int localPort = port;
           if (localPort == 0) {
               try {
  +                localPort = Integer.parseInt((String) pageContext.findAttribute(PORT));
  +            } catch (NumberFormatException ex) {
  +                /* Ignore */
  +            }
  +        }
  +        if (localPort == 0) {
  +            try {
                   localPort = Integer.parseInt(pageContext.getServletConfig().getInitParameter(PORT));
               } catch (NumberFormatException ex) {
                   /* Ignore */
  @@ -494,7 +515,15 @@
               /* SMTP default port number */
               localPort = 25;
           }
  -        props.put("mail.smtp.port", new Integer(localPort).toString());
  +        props.put("mail.smtp.port", Integer.toString(localPort));
  +
  +        /**
  +         * Store the server port in page scope, so additional sign and/or encrypt
  +         * tags access the same SMTP server and port, as these tags have to create a
  +         * new MimeMessage(Session) object without having access to MailTag's
  +         * server and/or port attributes.
  +         */
  +        pageContext.setAttribute(PORT, Integer.toString(localPort));
   
           /* Set properties to deal will SendFailedExceptions: send to all legal addresses */
           props.put("mail.smtp.sendpartial", "true");
  
  
  
  1.2       +3 -1      jakarta-taglibs-sandbox/mailer2/src/org/apache/taglibs/mailer2/PartTag.java
  
  Index: PartTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs-sandbox/mailer2/src/org/apache/taglibs/mailer2/PartTag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PartTag.java	28 Jul 2004 02:22:15 -0000	1.1
  +++ PartTag.java	14 Aug 2004 12:24:36 -0000	1.2
  @@ -140,8 +140,10 @@
                   if (t.match("multipart/*")) {
                       parent.addPart(mbp);
                   } else {
  -                    throw new JspException("mt:part: can only be used if MailTag has a multipart/* type");
  +                    throw new JspException("mt:part: can only be used if parent mt:mail has type=\"multipart/related\" \"multipart/alternative\", or \"multipart/digest\"");
                   }
  +            } else {
  +                throw new JspException("mt:part should be child of mt:mail");
               }
           } catch (MessagingException ex) {
               throw new JspException(ex);
  
  
  
  1.2       +24 -28    jakarta-taglibs-sandbox/mailer2/src/org/apache/taglibs/mailer2/ReplyToTag.java
  
  Index: ReplyToTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs-sandbox/mailer2/src/org/apache/taglibs/mailer2/ReplyToTag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ReplyToTag.java	28 Jul 2004 02:22:15 -0000	1.1
  +++ ReplyToTag.java	14 Aug 2004 12:24:36 -0000	1.2
  @@ -53,20 +53,14 @@
       private String name = null;
   
       /**
  -     * The body content of recipient.
  +     * The body content of the tag.
        */
  -    private String body = null;
  -
  -    /**
  -     * Name of the tag
  -     */
  -    protected String tagName = null;
  +    protected String body = null;
   
       /**
        * Default zero-arg constructor.
        */
       public ReplyToTag() {
  -        tagName = "mt:addrecipient";
       }
   
       public int doStartTag() throws JspException {
  @@ -74,7 +68,7 @@
            * Reset attributes with no corresponding getters and setters to
            * enable tag reuse.
            */
  -        setBody(null);
  +        body = null;
   
           return EVAL_BODY_BUFFERED;
       }
  @@ -83,10 +77,10 @@
           BodyContent content = getBodyContent();
           if (content != null) {
               if (address != null) {
  -                throw new JspException(tagName + ": cannot have both attribute address and body content");
  +                throw new JspException("mt:replyto: cannot have both an address attribute and body content");
               }
   
  -            setBody(content.getString());
  +            body = content.getString();
               content.clearBody();
           }
   
  @@ -102,7 +96,7 @@
                   localAddress = getBody();
               }
               if (localAddress == null) {
  -                throw new JspException(tagName + ": no recipient specified in address attribute or body");
  +                throw new JspException("mt:replyto: no recipient specified in address attribute or body content");
               }
   
               String localName = name;
  @@ -115,6 +109,8 @@
               } catch (UnsupportedEncodingException ex) {
                   /* Ignore */
               }
  +        } else {
  +            throw new JspException("mt:replyto should be child of mt:mail");
           }
   
           return SKIP_BODY;
  @@ -147,22 +143,6 @@
       }
   
       /**
  -     * Returns the body content.
  -     * @return The body content
  -     */
  -    public String getBody() {
  -        return body;
  -    }
  -
  -    /**
  -     * Sets the body attribute.
  -     * @param body The body content
  -     */
  -    public void setBody(String body) {
  -        this.body = body;
  -    }
  -
  -    /**
        * Returns the real name.
        * @return The real name
        *
  @@ -180,4 +160,20 @@
       public void setName(String name) {
           this.name = name;
       }
  +
  +    /**
  +     * Returns the body content.
  +     * @return The body content
  +     */
  +    protected String getBody() {
  +        return body;
  +    }
  +
  +    /**
  +     * Sets the body content.
  +     * @param body The body content
  +     */
  +    protected void setBody(String body) {
  +        this.body = body;
  +    }
   }
  
  
  
  1.2       +6 -1      jakarta-taglibs-sandbox/mailer2/src/org/apache/taglibs/mailer2/SignTag.java
  
  Index: SignTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs-sandbox/mailer2/src/org/apache/taglibs/mailer2/SignTag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SignTag.java	28 Jul 2004 02:22:15 -0000	1.1
  +++ SignTag.java	14 Aug 2004 12:24:36 -0000	1.2
  @@ -23,6 +23,7 @@
   import java.security.KeyStore;
   import java.security.PrivateKey;
   import java.security.Security;
  +import java.security.NoSuchAlgorithmException;
   import java.security.cert.CertStore;
   import java.security.cert.CollectionCertStoreParameters;
   import java.security.cert.X509Certificate;
  @@ -137,7 +138,11 @@
   
               /* Store the signed message */
               pageContext.setAttribute(getVar(), signMessage(getMessage(), cert, privateKey), MailTag.getScopeType(getScope()));
  -        } catch (Exception ex) {
  +        } catch (IOException ex) {
  +            throw new JspException(ex);
  +        } catch (NoSuchAlgorithmException ex) {
  +            throw new JspException(ex);
  +        } catch (GeneralSecurityException ex) {
               throw new JspException(ex);
           }
   
  
  
  
  1.2       +36 -41    jakarta-taglibs-sandbox/mailer2/src/org/apache/taglibs/mailer2/Validator.java
  
  Index: Validator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs-sandbox/mailer2/src/org/apache/taglibs/mailer2/Validator.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Validator.java	28 Jul 2004 02:22:15 -0000	1.1
  +++ Validator.java	14 Aug 2004 12:24:36 -0000	1.2
  @@ -17,13 +17,15 @@
   package org.apache.taglibs.mailer2;
   
   import java.util.Stack;
  -import java.util.Vector;
  +import java.util.ArrayList;
  +import java.io.IOException;
   
   import javax.servlet.jsp.tagext.PageData;
   import javax.servlet.jsp.tagext.TagLibraryValidator;
   import javax.servlet.jsp.tagext.ValidationMessage;
   import javax.xml.parsers.SAXParser;
   import javax.xml.parsers.SAXParserFactory;
  +import javax.xml.parsers.ParserConfigurationException;
   
   import org.xml.sax.Attributes;
   import org.xml.sax.SAXException;
  @@ -40,7 +42,7 @@
       /**
        * Vector with errorMessages.
        */
  -    private Vector errorMessages = new Vector();
  +    private ArrayList errorMessages = new ArrayList();
   
       /**
        * Default zero-arg constructor.    
  @@ -62,7 +64,11 @@
               factory.setValidating(true);
               SAXParser parser = factory.newSAXParser();
               parser.parse(pageData.getInputStream(), new MailerSAXHandler());
  -        } catch (Exception ex) {
  +        } catch (IOException ex) {
  +            errorMessages.add(ex.getClass().getName() + " parsing document: " + ex.getMessage());
  +        } catch (ParserConfigurationException ex) {
  +            errorMessages.add(ex.getClass().getName() + " parsing document: " + ex.getMessage());
  +        } catch (SAXException ex) {
               errorMessages.add(ex.getClass().getName() + " parsing document: " + ex.getMessage());
           }
           /* ... and return any errors */
  @@ -114,28 +120,28 @@
           public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
               /* Only push mt: tags onto the stack */
               if (qName.startsWith("mt:")) {
  -                if (qName.equals("mt:mail")) {
  +                if ("mt:mail".equals(qName)) {
                       addError(!tagStack.empty(), "mt:mail should be root tag");
   
                       for (int i = 0; i < attributes.getLength(); i++) {
  -                        if (attributes.getLocalName(i).equals("to")) {
  +                        if ("to".equals(attributes.getLocalName(i))) {
                               anyRecipients = true;
                           }
  -                        if (attributes.getLocalName(i).equals("cc")) {
  +                        if ("cc".equals(attributes.getLocalName(i))) {
                               anyRecipients = true;
                           }
  -                        if (attributes.getLocalName(i).equals("bcc")) {
  +                        if ("bcc".equals(attributes.getLocalName(i))) {
                               anyRecipients = true;
                           }
                       }
  -                } else if (qName.equals("mt:addrecipient")) {
  -                    addError(tagStack.empty() || !tagStack.peek().equals("mt:mail"),
  +                } else if ("mt:addrecipient".equals(qName)) {
  +                    addError(tagStack.empty() || !"mt:mail".equals(tagStack.peek()),
                           "mt:addrecipient requires mt:mail parent tag");
                       addError(!checkAttribute(attributes, "type"),
                           "mt:addrecipient requires type attribute");
                       anyRecipients = true;
  -                } else if (qName.equals("mt:attach")) {
  -                    addError(tagStack.empty() || !tagStack.peek().equals("mt:mail") && !tagStack.peek().equals("mt:part"),
  +                } else if ("mt:attach".equals(qName)) {
  +                    addError(tagStack.empty() || !"mt:mail".equals(tagStack.peek()) && !"mt:part".equals(tagStack.peek()),
                           "mt:attach requires mt:mail or mt:part parent tag");
   
                       int nAttrs = 0;
  @@ -149,34 +155,25 @@
                           nAttrs += checkAttribute(attributes, "name") ? 1 : 0;
                           addError(nAttrs != 2, "mt:attach requires both type and name attributes");
                       }
  -                } else if (qName.equals("mt:header")) {
  -                    addError(tagStack.empty() || !tagStack.peek().equals("mt:mail") && !tagStack.peek().equals("mt:part"),
  +                } else if ("mt:header".equals(qName)) {
  +                    addError(tagStack.empty() || !"mt:mail".equals(tagStack.peek()) && !"mt:part".equals(tagStack.peek()),
                           "mt:header requires mt:mail or mt:part parent tag");
  -                    addError(!checkAttribute(attributes, "name"),
  -                        "mt:header requires name attribute");
  -                } else if (qName.equals("mt:part")) {
  -                    addError(tagStack.empty() || !tagStack.peek().equals("mt:mail"),
  -                        "mt:part requires mt:mail parent tag");
  -                } else if (qName.equals("mt:send")) {
  -                    addError(!tagStack.empty(),
  -                        "mt:send should not be nested");
  -                    addError(!checkAttribute(attributes, "message"),
  -                        "mt:send requires message attribute");
  -                } else if (qName.equals("mt:replyto")) {
  -                    addError(tagStack.empty() || !tagStack.peek().equals("mt:mail"),
  -                        "mt:replyto requires mt:mail parent tag");
  -                } else if (qName.equals("mt:sign")) {
  -                    addError(!tagStack.empty(),
  -                        "mt:sign should not be nested");
  -                } else if (qName.equals("mt:encrypt")) {
  -                    addError(!tagStack.empty(),
  -                        "mt:encrypt should not be nested");
  -                } else if (qName.equals("mt:save")) {
  -                    addError(!tagStack.empty(),
  -                        "mt:save should not be nested");
  -                } else if (qName.equals("mt:load")) {
  -                    addError(!tagStack.empty(),
  -                        "mt:load should not be nested");
  +                    addError(!checkAttribute(attributes, "name"), "mt:header requires name attribute");
  +                } else if ("mt:part".equals(qName)) {
  +                    addError(tagStack.empty() || !"mt:mail".equals(tagStack.peek()), "mt:part requires mt:mail parent tag");
  +                } else if ("mt:send".equals(qName)) {
  +                    addError(!tagStack.empty(), "mt:send should not be nested");
  +                    addError(!checkAttribute(attributes, "message"), "mt:send requires message attribute");
  +                } else if ("mt:replyto".equals(qName)) {
  +                    addError(tagStack.empty() || !"mt:mail".equals(tagStack.peek()), "mt:replyto requires mt:mail parent tag");
  +                } else if ("mt:sign".equals(qName)) {
  +                    addError(!tagStack.empty(), "mt:sign should not be nested");
  +                } else if ("mt:encrypt".equals(qName)) {
  +                    addError(!tagStack.empty(), "mt:encrypt should not be nested");
  +                } else if ("mt:save".equals(qName)) {
  +                    addError(!tagStack.empty(), "mt:save should not be nested");
  +                } else if ("mt:load".equals(qName)) {
  +                    addError(!tagStack.empty(),"mt:load should not be nested");
                   } else {
                       addError(true, "Unknown tag " + qName);
                   }
  @@ -205,8 +202,7 @@
            */
           public void endDocument() throws SAXException {
               /* Final check */
  -            addError(mailTag && !anyRecipients,
  -                "mt:mail should have at least one to, cc, or bcc attributes or one or more mt:addrecipient child tags");
  +            addError(mailTag && !anyRecipients, "mt:mail should have at least one to, cc, or bcc attributes or one or more mt:addrecipient child tags");
           }
   
   
  @@ -219,7 +215,6 @@
           public boolean checkAttribute(Attributes attributes, String name) {
               for (int i = 0; i < attributes.getLength(); i++) {
                   if (name.equals(attributes.getLocalName(i))) {
  -                    //System.out.println("Checking attribute " + name + " " + attributes.getLocalName(i));
                       return true;
                   }
               }
  
  
  
  1.2       +18 -18    jakarta-taglibs-sandbox/mailer2/xml/mailer2.xml
  
  Index: mailer2.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs-sandbox/mailer2/xml/mailer2.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- mailer2.xml	28 Jul 2004 02:22:15 -0000	1.1
  +++ mailer2.xml	14 Aug 2004 12:24:36 -0000	1.2
  @@ -32,7 +32,7 @@
                       <li>Send messages in a background thread for better response times, or directly to get better feedback</li>
                       <li>Use JSTL 1.1 EL throughout</li>
                       <li>PLAIN or LOGIN SMTP authentication</li>
  -                    <li>Configure server, port, username and password from your web.xml</li>
  +                    <li>Configure server, port, username and password with context-params in the application's web.xml</li>
                       <li>Load previosly stored messages, or save messages to disk</li>
                       <li>S/MIME sign or sign and encrypt messages using a <a href="http://www.bouncycastle.org">Legion of the Bouncy Castle</a> implementation of the S/MIME protocol</li>
                   </ul>
  @@ -50,7 +50,7 @@
           <requirements-info>
               This tag library requires the following:
               <ul>
  -                <li><a href="http://java.sun.com/j2se/">JDK 1.4</a></li>
  +                <li><a href="http://java.sun.com/j2se/">JDK 1.4</a> or higher</li>
                   <li>mail.jar and activation.jar from a <a href="http://java.sun.com/j2ee/">J2EE 1.4</a> distribution</li>
                   <li>bcprov-jdkX-Y.jar and bcmail-jdkX-Y.jar from <a href="http://www.bouncycastle.org">http://www.bouncycastle.org</a> where X is the JVM version and Y is the current BC version, e.g. <a href="http://www.bouncycastle.org/download/bcprov-jdk14-124.jar">bcprov-jdk14-124.jar</a> and <a href="http://www.bouncycastle.org/download/bcmail-jdk14-124.jar">bcmail-jdk14-124.jar</a></li>
                   <li>JSP 2.0 container, like <a href="http://jakarta.apache.org/tomcat/">Tomcat 5.x</a> or <a href="http://www.caucho.com/">Resin 3.x</a></li>
  @@ -207,7 +207,7 @@
   <mt:mail subject="Test mail" from="john.doe@example.com" server="smtp.example.com">
       <mt:addrecipient type="to">jane.doe@example.com</mt:addrecipient>
       Hi Jane, attached is the file you requested.
  -    <mt:attach file="c:/work/document.doc"/>
  +    <mt:attach filename="c:/work/document.doc"/>
   </mt:mail>
   
   <mt:mail subject="Test mail" from="john.doe@example.com"
  @@ -243,7 +243,7 @@
                   </example>
               </tag>
               <tag>
  -                <description><![CDATA[JSP tag mt:header is used to set additional headers in an e-mail message. It is a child of mt:mail or mt:part.]]></description>
  +                <description><![CDATA[JSP tag <mt:header> is used to set additional headers in an e-mail message. It is a child of <mt:mail> or <mt:part>.]]></description>
                   <display-name>mt:header</display-name>
                   <name>header</name>
                   <tag-class>org.apache.taglibs.mailer2.HeaderTag</tag-class>
  @@ -276,7 +276,7 @@
                   </example>
               </tag>
               <tag>
  -                <description><![CDATA[JSP tag mt:addrecipient is used to add recipients to an e-mail message. It is a child of mt:mail.]]></description>
  +                <description><![CDATA[JSP tag <mt:addrecipient> is used to add recipients to an e-mail message. It is a child of <mt:mail>.]]></description>
                   <display-name>mt:addrecipient</display-name>
                   <name>addrecipient</name>
                   <tag-class>org.apache.taglibs.mailer2.AddRecipientTag</tag-class>
  @@ -318,7 +318,7 @@
                   </example>
               </tag>
               <tag>
  -                <description><![CDATA[JSP tag mt:attach is used to add attachments. It is a child of mt:mail or mt:part. Either the url, or the file, or the message or both name and type attributes should be present. If the url attribute is present, the name and type are derived from the HTTP response. If the filename attribute is present, the name and type are also automatically derived. If the message attribute is present, the type is "message/rc822" and the name is the subject of the attached message. If both name and type are present, the body content of the tag is added as an attachment.]]></description>
  +                <description><![CDATA[JSP tag <mt:attach> is used to add attachments. It is a child of <mt:mail> or <mt:part>. Either the url, or the file, or the message or both name and type attributes should be present. If the url attribute is present, the name and type are derived from the HTTP response. If the filename attribute is present, the name and type are also automatically derived. If the message attribute is present, the type is "message/rc822" and the name is the subject of the attached message. If both name and type are present, the body content of the tag is added as an attachment.]]></description>
                   <display-name>mt:attach</display-name>
                   <name>attach</name>
                   <tag-class>org.apache.taglibs.mailer2.AttachTag</tag-class>
  @@ -372,7 +372,7 @@
                       <usage>
                           <comment>Example usage of the attach tag.</comment>
                           <code><![CDATA[
  -<mt:attach file="c:/temp/example.txt"/>
  +<mt:attach filename="c:/temp/example.txt"/>
   
   <mt:attach url="http://jakarta.apache.org/images/jakarta-logo.gif"/>
   
  @@ -398,7 +398,7 @@
                   </example>
               </tag>
               <tag>
  -                <description><![CDATA[JSP tag mt:part is used to create a multipart mail. It is used for multipart/alternative HTML and plain text mail alternatives or multipart/digest messages that contain several messages. It is a child of mt:mail. It can have mt:header and mt:attach tags as children. Multiple mt:parts can be added to a mt:mail tag. The type attribute of mt:mail should then be one of the multipart/* variants, e.g. multipart/mixed, multipart/related or multipart/alternative. The attachments inside mt:part and its optional body content are assumed to be multipart/related. This enables the creation of HTML formatted e-mail. References to images should be be made using cid: URLs. ]]></description>
  +                <description><![CDATA[JSP tag <mt:part> is used to create a multipart mail. It is used for HTML and plain text multipart mail alternatives or multipart/digest messages that contain several messages. It is a child of <mt:mail>. Allowed children are <mt:header> and <mt:attach>. Multiple <mt:parts> can be added to an <mt:mail> tag. The type attribute of <mt:mail> should then be one of the multipart/* variants, e.g. multipart/mixed, multipart/related or multipart/alternative. The attachments inside <mt:part> and its optional body content are assumed to be multipart/related. This enables the creation of HTML formatted e-mail. References to images should be be made using cid: URLs. ]]></description>
                   <display-name>mt:part</display-name>
                   <name>part</name>
                   <tag-class>org.apache.taglibs.mailer2.PartTag</tag-class>
  @@ -426,7 +426,7 @@
                   </example>
               </tag>
               <tag>
  -                <description><![CDATA[JSP tag <b>mt:send</b> is used to send a previously stored message. mt:send does not have any child tags.]]></description>
  +                <description><![CDATA[JSP tag <mt:send> is used to send a previously stored message. <mt:send> does not have any child tags.]]></description>
                   <display-name>mt:send</display-name>
                   <name>send</name>
                   <tag-class>org.apache.taglibs.mailer2.SendTag</tag-class>
  @@ -462,7 +462,7 @@
                   </example>
               </tag>
               <tag>
  -                <description><![CDATA[JSP tag mt:replyto is used to add reply-to addresses to an e-mail message. It is a child of mt:mail.]]></description>
  +                <description><![CDATA[JSP tag <mt:replyto> is used to add reply-to addresses to an e-mail message. It is a child of mt:mail.]]></description>
                   <display-name>mt:replyto</display-name>
                   <name>replyto</name>
                   <tag-class>org.apache.taglibs.mailer2.ReplyToTag</tag-class>
  @@ -497,7 +497,7 @@
           </tagtoc>
           <tagtoc name="S/MIME signing and encryption tags">
               <tag>
  -                <description><![CDATA[JSP tag mt:sign is used to S/MIME sign a previously stored message. mt:sign does not have any child tags.]]></description>
  +                <description><![CDATA[JSP tag <mt:sign> is used to S/MIME sign a previously stored message. <mt:sign> does not have any child tags.]]></description>
                   <display-name>mt:sign</display-name>
                   <name>sign</name>
                   <tag-class>org.apache.taglibs.mailer2.SignTag</tag-class>
  @@ -570,7 +570,7 @@
                   </example>
               </tag>
               <tag>
  -                <description><![CDATA[JSP tag mt:encrypt is used to S/MIME encrypt a previously stored message. mt:encrypt does not have any child tags.]]></description>
  +                <description><![CDATA[JSP tag <mt:encrypt> is used to S/MIME encrypt a previously stored message. <mt:encrypt> does not have any child tags.]]></description>
                   <display-name>mt:encrypt</display-name>
                   <name>encrypt</name>
                   <tag-class>org.apache.taglibs.mailer2.EncryptTag</tag-class>
  @@ -645,7 +645,7 @@
           </tagtoc>
           <tagtoc name="Loading and saving messages">
               <tag>
  -                <description><![CDATA[JSP tag mt:save is used to save a previously stored message to the file system. mt:save does not have any child tags.]]></description>
  +                <description><![CDATA[JSP tag <mt:save> is used to save a previously stored message to the file system. <mt:save> does not have any child tags.]]></description>
                   <display-name>mt:save</display-name>
                   <name>save</name>
                   <tag-class>org.apache.taglibs.mailer2.SaveTag</tag-class>
  @@ -662,7 +662,7 @@
                   </attribute>
                   <attribute>
                       <description>The location to save the message</description>
  -                    <name>file</name>
  +                    <name>filename</name>
                       <required>yes</required>
                       <rtexprvalue>yes</rtexprvalue>
                       <availability>1.0</availability>
  @@ -676,13 +676,13 @@
       Hi Jane, here's my first mail
   </mt:mail>
   </mt:sign message="${message}" var="signedMessage" .../>
  -<mt:save message="${signedMessage}" file="signed.message"/>
  +<mt:save message="${signedMessage}" filename="signed.message"/>
   ]]></code>
                       </usage>
                   </example>
               </tag>
               <tag>
  -                <description><![CDATA[JSP tag mt:load is used to load a message from the file system. mt:load does not have any child tags.]]></description>
  +                <description><![CDATA[JSP tag <mt:load> is used to load a message from the file system. <mt:load> does not have any child tags.]]></description>
                   <display-name>mt:load</display-name>
                   <name>load</name>
                   <tag-class>org.apache.taglibs.mailer2.LoadTag</tag-class>
  @@ -691,7 +691,7 @@
                   <restrictions>None</restrictions>
                   <attribute>
                       <description>The location to load the message from</description>
  -                    <name>file</name>
  +                    <name>filename</name>
                       <required>yes</required>
                       <rtexprvalue>yes</rtexprvalue>
                       <availability>1.0</availability>
  @@ -714,7 +714,7 @@
                       <usage>
                           <comment>Example usage of the load tag.</comment>
                           <code><![CDATA[
  -<mt:load var="message" file="signed.message"/>
  +<mt:load var="message" filename="signed.message"/>
   <mt:send message="${message}"/>
   ]]></code>
                       </usage>
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-dev-help@jakarta.apache.org


Mime
View raw message