JSP Tag Libraries

Скачать в pdf «JSP Tag Libraries»


О Sends the email The fact that most of the JavaMail objects are created in checkPa-rameters() makes it possible to substantially simplify sendMail(). Now it merely sets the already instantiated addresses as well as the subject and body into the Java-Mail message object and sends it using the transport object.

The revised TLD entry


Our new TLD entry should now resemble the following (note how “server” and “from” are no longer required attributes):


<tag>


<name>sender</name>


<tagclass>book.mail.JavaMailTag</tagclass>


<teiclass>book.mail.MailTagExtraInfo</teiclass> <bodycontent>empty</bodycontent>


<info>


Sends an email based on the provided attributes and application configuration.


The user can specify the SMTP server address and the sender’s identity using context parameter. He can also provide an already initialized JavaMail session object to be used when sending the email.


</info> <attribute>


<name>server</name> <required>false</required> О <rtexprvalue>false</rtexprvalue> </attribute>


<attribute>


<name>from</name> <required>false</required> О <rtexprvalue>true</rtexprvalue> </attribute>


<attribute>


<name>to</name>


<required>true</required>


<rtexprvalue>true</rtexprvalue>


</attribute>


<attribute>


<name>subj ect</name> <required>false</required> <rtexprvalue>true</rtexprvalue> </attribute>


<attribute>


<name>body</name>


<required>true</required>


<rtexprvalue>true</rtexprvalue>


</attribute>


</tag>

О Neither the from nor server attribute is mandatory.
7.3.5 The JavaMailTag in action


Armed with our new JavaMailTag and TLD, we can now implement improved JSP files that provide increased management over the mail parameters. To demonstrate the working of and advantages associated with the new tag, let’s develop a simple registration application. The application’s role is to allow users to register themselves at an online resource. Access to the resource requires a user name and password that the registration application emails to the user.

Скачать в pdf «JSP Tag Libraries»