The shopping cart example we have reviewed allowed the user to send an email to the Webmaster for the site. This provides an opportunity to examine the use of JavaMail in a Web application. The JSP page shown next demonstrates how this is done.
The MailService (examples.javamail.MailService) class provides a simplified access to the JavaMail API. We also access the user bean from the session to allow us to fill in the values for some of the fields in the form.
This page is an HTML form and contains various input tags to gather information about the email. The from email address is provided on one of these lines. We use the value attribute for the input tag to set the value to that of the email address of the reader.