[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: java template emailer
It might be easier for you not to use JSP to format the message.
It would be faster and simpler to just hold the HTML in some structure
(giant StringBuffer, xml Document, etc.) and put the data in yourself. The
problem with calling your JSP is that you'll be using a lot of processor
cycles and network traffic just to do replacements for you.
You can do something like this:
have a map with all of your replacement variables and names for each user:
Then have a SringBuffer that contains this:
"Hello <%=name%> how are you? We are emailing you at <%=email%>...."
Then write a while loop to replace all the <%=%>'s with the values from the
Map. It's very exensible, quick and doesn't require a JSP engine.
>From: "Chad Smith" <email@example.com>
>Subject: java template emailer
>Date: Fri, 1 Mar 2002 09:35:23 -0500
>Received: from [126.96.36.199] by hotmail.com (3.2) with ESMTP id
>MHotMailBE48DD1800594136E80A422D12B481F20; Fri, 01 Mar 2002 06:37:24 -0800
>Received: (from list@localhost)by www.ajug.org (8.11.2/8.11.2) id
>g21FgCm01959;Fri, 1 Mar 2002 10:42:12 -0500
>From firstname.lastname@example.org Fri, 01 Mar 2002 06:39:04 -0800
>Resent-Date: Fri, 1 Mar 2002 10:42:12 -0500
>X-Priority: 3 (Normal)
>X-Mailer: Microsoft Outlook, Build 10.0.2616
>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
>X-Mailing-List: <email@example.com> archive/latest/3
>I'm trying to create a marketing campaign emailer for a client that
>will let me send out a template JSP file that i will populate with data
>from a data source.
>For example, I have a TreeSet of data where each index holds personal
>information about a user (name, email address, city, etc.)
>I want to send out an HTML/JSP email as follows:
>Thank you for purchasing <%=PRODUCT%>.
>Please let us know if you are satisfied with the product:
><HERE IS A DROPDOWNLIST>
>Now the problem i'm having is ...I know how to display this information
>for each person in the TreeSet (using a forward or include), but
>how do i send the completed jsp/html email to that person?
> I know that I can do the following:
>URL thePage = new URL("http://www.yoursite.com/yourjsp.jsp");
>URLConnection conn = thePage.openConnection();
>InputStream is = conn.getInputStream();
> // read from this InputStream
>Then you can direct the data from that InputStream into the e-mail body.
>But i'm pretty sure this will send out the jsp without having first
>I need to figure out a way to either compile the jsp and then send it,
>or compile it to some sort of .html file and send it.
>I also need to find the most efficient way of doing this since the
>client could be sending large campaigns of emails.
>Thanks for your time!
>"May the road rise to meet you."
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.