JavaZOOM Web Site
  Software
  
Installation
  
Configuration
  
Customization
  
License

<< back

- Customization -

jMailComposer JSP files could be customized to your own web design and language. It provides a blank template (no images, no colors, no css, ...) as a starting point. You could also include custom fields (customerID, productID, ...) coming HTML form into email message.

  Step1 : Blank Template

blank/ folder included in jMailComposer package is a template you need to start customization.

  • First, copy blank folder to a new folder (let's say custom/).
  • Second, edit custom/compose.jsp to setup jMailComposer properties. You have to fill in SMTP Server with a valid IP address or server name. Charset property is not mandatory but you should setup it matching to your country. Commons values are (iso-8859-1, big5 ...), default one is utf-8. Here is a sample including hardcoded fromemail and fromname properties :
    <%-- ComposeBean Setup : Begin --%>
    <jsp:useBean id="composebean" scope="session" class="javazoom.sendmail.ComposeBean"/>
    <jsp:setProperty name="composebean" property="smtpserver" value="smtp.company.com"/>
    <jsp:setProperty name="composebean" property="fromemail" value="support@javazoom.net"/>
    <jsp:setProperty name="composebean" property="fromname" value="JavaZOOM"/>
    <jsp:setProperty name="composebean" property="allowattachment" value="true"/>
    <jsp:setProperty name="composebean" property="charset" value="iso-8859-1"/>
    <%-- ComposeBean Setup : End --%>
  • Finally you have to add this custom jMailComposer to your webapp's deployment descriptor : web.xml
    [...]
    <servlet-mapping>
      <servlet-name>uploadservlet</servlet-name>
      <url-pattern>/custom/attach</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
      <servlet-name>sendmailservlet</servlet-name>
      <url-pattern>/custom/attachform</url-pattern>
    </servlet-mapping>
    <servlet-mapping>

      <servlet-name>sendmailservlet</servlet-name>
      <url-pattern>/custom/compose</url-pattern>
    </servlet-mapping>
    <servlet-mapping>

      <servlet-name>sendmailservlet</servlet-name>
      <url-pattern>/custom/composenew</url-pattern>
    </servlet-mapping>
    <servlet-mapping>

      <servlet-name>sendmailservlet</servlet-name>
      <url-pattern>/custom/sendmail</url-pattern>
    </servlet-mapping>
    <servlet-mapping>

      <servlet-name>uploadservlet</servlet-name>
      <url-pattern>/custom/unattach</url-pattern>
    </servlet-mapping>
    </web-app>

Note that if you don't want to allow attachments, you could delete attach.jsp and attachstatus.jsp.

 Step 2 : Add your own web design

Edit custom/compose.jsp to add your own HTML code :

  • First, remove all HTML fields you don't need. According to our custom sample, we could remove "From" and "From name".
  • Second, remove JavaZOOM's header and footer tables linking to others samples.
  • Finally, add own own tables, images, colors ... apply your own CSS but pay attention to NOT REMOVE Java/JSP code nor JavaScript code (especially onLoad call on BODY tag). You could add HTML form fields that you want be included in the email message (e.g. ProductID from a product list, Customer phone number, ...). Learn more about that in Step 3.

Do the same for all others JSP files : mailsent.jsp, attach.jsp, attachstatus.jsp.

 Step 3 : Custom fields

A good sample usage of custom fields is included in contact/ sample. contact/compose.jsp allows to add 2 form fields. First one is a productID coming from a product list. Second one is a customer's phone number. Once declared as following, both will be included in the email message :

[...]
<select name="Product">
  <option value="No product selected" selected>- Select a product -</option>
  <option value="ProductID1">Product Name1</option>
  <option value="ProductID2">Product Name2</option>
  <option value="ProductID3">Product Name3</option>
  <option value="ProductID4">Product Name4</option>
  <option value="ProductID5">Product Name5</option>
</select>
[...]
<input type="text" name="Day phone" value="<%= composebean.getCustomvalue("Day phone") %>" size="28">
[...]
<%-- Custom fields list setup : Begin --%>
<input type="hidden" name="<%= ComposeBean.CUSTOM %>" value="Day phone:Product">
<%-- Custom fields list setup : End --%>

[...]

 

[News] [Applets] [Servlets] [Services] [Projects] [Links] [About]

Copyright © JavaZOOM 1999-2003

Java is a trademark of Sun Microsystems,Inc. All other company and/or product names are the property of their respective owners.