You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Franck Lefebure <fl...@orangecaraibe.com> on 2004/10/20 18:02:33 UTC

use strutsed jsp as email template ?

Hello,

I would like to know if there is a way to use a jsp file to format an email body
(something like a velocity template)

(I don't want to embed emailer custom tags in the jsp)

In my idea I would like to find a way to do something like that :

------------------------------
example.jsp :
------------------------------
<%@ taglib uri="/WEB-INF/tlds/struts-bean.tld" prefix="bean" %>
<html>
Some String : <bean:write name="myBean">
</html>
-----------------------------
example.java :
-----------------------------
Template myEmailTemplate = new Template("example.jsp");
myEmailTemplate.setAttribute("request", "myBean", "the value of my string");
String messageBody = myEmailTemplate.format();



Any idea ?
--
Franck Lefebure
equipe web http://www.orangecaraibe.com

Re: use strutsed jsp as email template ?

Posted by Joe Germuska <Jo...@Germuska.com>.
You might be able to use java.net.URL or something like it to have 
your Java code call for the page and use its contents.  It seems 
awkward and might not fit into an offline application, but it's 
possible in theory.

Since JSPs are fundamentally servlets, I don't see anyway you could 
do this in the absence of a Servlet container.

Joe


At 12:02 PM -0400 10/20/04, Franck Lefebure wrote:
>Hello,
>
>I would like to know if there is a way to use a jsp file to format 
>an email body
>(something like a velocity template)
>
>(I don't want to embed emailer custom tags in the jsp)
>
>In my idea I would like to find a way to do something like that :
>
>------------------------------
>example.jsp :
>------------------------------
><%@ taglib uri="/WEB-INF/tlds/struts-bean.tld" prefix="bean" %>
><html>
>Some String : <bean:write name="myBean">
></html>
>-----------------------------
>example.java :
>-----------------------------
>Template myEmailTemplate = new Template("example.jsp");
>myEmailTemplate.setAttribute("request", "myBean", "the value of my string");
>String messageBody = myEmailTemplate.format();
>
>
>
>Any idea ?
>--
>Franck Lefebure
>equipe web http://www.orangecaraibe.com


-- 
Joe Germuska            
Joe@Germuska.com  
http://blog.germuska.com    
"In fact, when I die, if I don't hear 'A Love Supreme,' I'll turn 
back; I'll know I'm in the wrong place."
    - Carlos Santana

RE: use strutsed jsp as email template ?

Posted by Matthias Wessendorf <ma...@matthias-wessendorf.de>.
Hi,

on commons-dev there was at begin of October
a discussion in Commons Email project and
Velocity templates.
Perhaps you could benefit from that mails
(I have no details in my mind, only the happend
discussion)

Regards,
Matthias

> -----Original Message-----
> From: Hubert Rabago [mailto:hrabago@gmail.com] 
> Sent: Wednesday, October 20, 2004 6:49 PM
> To: Struts Users Mailing List
> Subject: Re: use strutsed jsp as email template ?
> 
> 
> The short answer is no.
> Take a look at velocity at 
> http://jakarta.apache.org/velocity/index.html .
> 
> 
> On Wed, 20 Oct 2004 12:02:33 -0400, Franck Lefebure 
> <fl...@orangecaraibe.com> wrote:
> > Hello,
> > 
> > I would like to know if there is a way to use a jsp file to 
> format an 
> > email body (something like a velocity template)
> > 
> > (I don't want to embed emailer custom tags in the jsp)
> > 
> > In my idea I would like to find a way to do something like that :
> > 
> > ------------------------------
> > example.jsp :
> > ------------------------------
> > <%@ taglib uri="/WEB-INF/tlds/struts-bean.tld" 
> prefix="bean" %> <html>
> > Some String : <bean:write name="myBean">
> > </html>
> > -----------------------------
> > example.java :
> > -----------------------------
> > Template myEmailTemplate = new Template("example.jsp");
> > myEmailTemplate.setAttribute("request", "myBean", "the 
> value of my string");
> > String messageBody = myEmailTemplate.format();
> > 
> > Any idea ?
> > --
> > Franck Lefebure
> > equipe web http://www.orangecaraibe.com
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: use strutsed jsp as email template ?

Posted by Hubert Rabago <hr...@gmail.com>.
The short answer is no.
Take a look at velocity at http://jakarta.apache.org/velocity/index.html .


On Wed, 20 Oct 2004 12:02:33 -0400, Franck Lefebure
<fl...@orangecaraibe.com> wrote:
> Hello,
> 
> I would like to know if there is a way to use a jsp file to format an email body
> (something like a velocity template)
> 
> (I don't want to embed emailer custom tags in the jsp)
> 
> In my idea I would like to find a way to do something like that :
> 
> ------------------------------
> example.jsp :
> ------------------------------
> <%@ taglib uri="/WEB-INF/tlds/struts-bean.tld" prefix="bean" %>
> <html>
> Some String : <bean:write name="myBean">
> </html>
> -----------------------------
> example.java :
> -----------------------------
> Template myEmailTemplate = new Template("example.jsp");
> myEmailTemplate.setAttribute("request", "myBean", "the value of my string");
> String messageBody = myEmailTemplate.format();
> 
> Any idea ?
> --
> Franck Lefebure
> equipe web http://www.orangecaraibe.com
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: use strutsed jsp as email template ?

Posted by Niall Pemberton <ni...@blueyonder.co.uk>.
I'm sure I had a discussion about this sort of thing with someone on this
list, but for the life of me I can't think who.

You could write your own custom tag which just stores its body's contents in
a bean's property, so you would have something like...

<custom:store name="myBean" property="emailText">
   <html>
    Some String : <bean:write name="myBean">
    </html>
</custom:store>

Then in your action get a RequestDispatcher and do an include

EmailBean emailBean = new EmailBean();
request.setAttribute("myBean", emailBean );
javax.servlet.RequestDispatcher rd =
request.getRequestDispatcher("/myEmailTemplate.jsp");
rd.include(request, response);
String emailText = emailBean.getEmailText();



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org