You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Chris Miles <ch...@chrismiles.org> on 2010/07/07 21:38:38 UTC
Emailing the contents of a Struts2 view?
Is it posible for me to render a view after an action and be able to access the HTML for sending in an email rather than rendering to a browser?
thanks
Chris
Re: Emailing the contents of a Struts2 view?
Posted by Dale Newfield <da...@newfield.org>.
I'm pretty certain this is not a good idea, but it's a hack that's been
floating in my head: If you use sitemesh, you could make a decorator
that captures the full message, does something with it, then echoes it
again.
basically:
<c:set scope="request" var="theFullMonty"><decorator:body/></c:set>
<s:property value="%{sendEmail(#request.theFullMonty)}"/>
<s:property value="%{#request.theFullMonty}"/>
-Dale
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Emailing the contents of a Struts2 view?
Posted by Paweł Wielgus <po...@gmail.com>.
Hi All,
two more things, such an e-mail should not contains external css
source or backgrounds and there is a service that can make emailable
version of a html page automaticaly from your source html, i have used
it once but i don't remember the address so use google to find it.
Best greetings,
Paweł Wielgus.
2010/7/8 <ch...@chrismiles.org>:
> Yeah. Thank you both for your responses. I think I will need to justify
> the benefits of the extra cost for a fancy HTML invoice compared to a
> plain text version.
>
> Thanks again folks. I will investigate :)
>
> Chris
>
>>> Yes, tricky indeed, but currently the only way to go.
>>
>> Not the only way. Just because you use jsp to render pages doesn't mean
>> that's the only way to render them. You could render that page with
>> freemarker or velocity (or, or, or) which can more easily be rendered
>> programmatically by your action, the output of which can then be
>> packaged however you want and shipped wherever you want. There are a
>> number of hurdles no matter how you generate the content for the e-mail
>> message, and the pointers in Robert's post will help you. If you want
>> to look at an example where velocity is used, check out appfuse.
>>
>> -Dale
>>
>> ---------------------------------------------------------------------
>> 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
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Emailing the contents of a Struts2 view?
Posted by ch...@chrismiles.org.
Yeah. Thank you both for your responses. I think I will need to justify
the benefits of the extra cost for a fancy HTML invoice compared to a
plain text version.
Thanks again folks. I will investigate :)
Chris
>> Yes, tricky indeed, but currently the only way to go.
>
> Not the only way. Just because you use jsp to render pages doesn't mean
> that's the only way to render them. You could render that page with
> freemarker or velocity (or, or, or) which can more easily be rendered
> programmatically by your action, the output of which can then be
> packaged however you want and shipped wherever you want. There are a
> number of hurdles no matter how you generate the content for the e-mail
> message, and the pointers in Robert's post will help you. If you want
> to look at an example where velocity is used, check out appfuse.
>
> -Dale
>
> ---------------------------------------------------------------------
> 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: Emailing the contents of a Struts2 view?
Posted by Dale Newfield <da...@newfield.org>.
On 7/8/10 10:37 AM, Robert Graf-Waczenski wrote:
> Yes, tricky indeed, but currently the only way to go.
Not the only way. Just because you use jsp to render pages doesn't mean
that's the only way to render them. You could render that page with
freemarker or velocity (or, or, or) which can more easily be rendered
programmatically by your action, the output of which can then be
packaged however you want and shipped wherever you want. There are a
number of hurdles no matter how you generate the content for the e-mail
message, and the pointers in Robert's post will help you. If you want
to look at an example where velocity is used, check out appfuse.
-Dale
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Emailing the contents of a Struts2 view?
Posted by Robert Graf-Waczenski <rg...@lsoft.com>.
Am 08.07.2010 15:44, schrieb chris@chrismiles.org:
> Thanks yeah I see what you mean. It would be easy to have a class generate
> tons of HTML but that would be cumbersome. Getting the resuling rendered
> JSP would be something tricky.
>
Yes, tricky indeed, but currently the only way to go. Our own app has
this capability. But since it is closed source, commercial and
everything, i will not share the source with you. I'll tell you so much,
however: Research how to program your own ServletResponse class that
captures the output written to it somewhere. Then use this custom
response to have a request dispatcher for your JSP write to. After this,
grab the resulting HTML from your response and create a correctly
formatted HTML multipart mail from it (see the JavaMail API for details
about how to do this).
The other remarks about JavaScript, absolute URLs, forms (iframes, ....)
of course still apply and you need to deal with this somehow. Oh, and
BTW, don't forget to have a suitably written plain text alternative.
Where do you get that from? Created from the HTML (yuck, trust me!)? Or
supplied elsewhere?
To summarize: Your approach to use a JSP to define the HTML part of an
email sounds good at first glance, but there is a lot to consider!
(Which in no way is related to Struts...)
Robert
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Emailing the contents of a Struts2 view?
Posted by ch...@chrismiles.org.
Thanks Dale.
It is basically for emailing a copy of a invoice which has been populated
by an action. No links or anything. All self contained except the CSS link
but that is absolute anyway.
Chris
> On 7/8/10 9:44 AM, chris@chrismiles.org wrote:
>> Getting the resuling rendered JSP would be something tricky.
>
> And not what you want. You'd still have to go through that output and
> modify all the relative links to make them absolute, and you sure don't
> want to have any javascript or forms in your email message as it's
> likely to be interpreted as spam. You may want it to look similar, but
> IMO you're barking up the wrong tree.
>
> -Dale
>
> ---------------------------------------------------------------------
> 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: Emailing the contents of a Struts2 view?
Posted by Dale Newfield <da...@newfield.org>.
On 7/8/10 9:44 AM, chris@chrismiles.org wrote:
> Getting the resuling rendered JSP would be something tricky.
And not what you want. You'd still have to go through that output and
modify all the relative links to make them absolute, and you sure don't
want to have any javascript or forms in your email message as it's
likely to be interpreted as spam. You may want it to look similar, but
IMO you're barking up the wrong tree.
-Dale
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Emailing the contents of a Struts2 view?
Posted by ch...@chrismiles.org.
Thanks yeah I see what you mean. It would be easy to have a class generate
tons of HTML but that would be cumbersome. Getting the resuling rendered
JSP would be something tricky.
> Hi,
>
> I am not exactly sure of such return type, but what you can try with is-
>
> Create a html output of the result and save it on server disk.
>
> Use this saved html file to embed in email, most email now support html/
> rich text emails.
>
> This i think may serve your purpose.
>
> As we used to mail pdf files as a result of action.
>
> You have a good point struts team must consider this as enhancement in
> future version, in case not supported directly now.
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Emailing the contents of a Struts2 view?
Posted by Amol Ghotankar <gh...@gmail.com>.
Hi,
I am not exactly sure of such return type, but what you can try with is-
Create a html output of the result and save it on server disk.
Use this saved html file to embed in email, most email now support html/
rich text emails.
This i think may serve your purpose.
As we used to mail pdf files as a result of action.
You have a good point struts team must consider this as enhancement in
future version, in case not supported directly now.
On Thu, Jul 8, 2010 at 6:36 PM, <ch...@chrismiles.org> wrote:
> Yeah that is right.
>
> I want to maintain the MVC pattern, but using it for sending HTML emails
> to clients rather than browser requests. It has to be the HTML within the
> email itself rather than embedding an iframe to the website or a link to a
> page.
>
> Chris
>
> > Hi,
> >
> > What you want is the content of the mail to have result of the called
> > action
> > right?
> >
> > i.e if my actions return list which is iterated on jsp and displayed on
> > jsp.
> >
> > So instead of showing it on browser u want to show it in the content of
> > mail???
> >
> > On Thu, Jul 8, 2010 at 2:10 PM, <ch...@chrismiles.org> wrote:
> >
> >> Hi.
> >>
> >> Thanks for the response but that is not what I mean. I want to email the
> >> contents of a view - a JSP which has been rendered after an action - but
> >> to the contents of an email rather than the contents of a browser
> >> request.
> >>
> >> Chris
> >>
> >> > If you just want to send mail after some action is executed then
> >> >
> >> > I think you can do it by using
> >> >
> >> > action-redirect
> >> >
> >> > You can redirect the action to send email action.
> >> >
> >> > Regards,
> >> >
> >> > Amol Ghotankar
> >> >
> >> > On Thu, Jul 8, 2010 at 1:08 AM, Chris Miles <ch...@chrismiles.org>
> >> wrote:
> >> >
> >> >> Is it posible for me to render a view after an action and be able to
> >> >> access
> >> >> the HTML for sending in an email rather than rendering to a browser?
> >> >>
> >> >> thanks
> >> >>
> >> >> Chris
> >> >
> >> >
> >> >
> >> >
> >> > --
> >> >
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >> For additional commands, e-mail: user-help@struts.apache.org
> >>
> >>
> >
> >
> > --
> >
> >
> > With Best Regards,
> >
> > Amol Ghotankar
> > Technical Director
> > Cursive Technologies Pvt. Ltd.
> > 104, A1 Wing, W Sector,
> > Masulkar Colony, Ajmera,
> > Pimpri, Pune-18 INDIA
> > O: +91 2020 270 570
> > M: +91 9960 980 419
> > www.cursivetech.com
> >
> >
> > CURSIVE TECHNOLOGIES EMAIL NOTICE
> > The information contained in this email and any attachments is
> > confidential
> > and may be subject to copyright or other intellectual property
> protection.
> > If you are not the intended recipient, you are not authorized to use or
> > disclose this information, and we request that you notify us by reply
> mail
> > or telephone and delete the original message from your mail system.
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
Re: Emailing the contents of a Struts2 view?
Posted by ch...@chrismiles.org.
Yeah that is right.
I want to maintain the MVC pattern, but using it for sending HTML emails
to clients rather than browser requests. It has to be the HTML within the
email itself rather than embedding an iframe to the website or a link to a
page.
Chris
> Hi,
>
> What you want is the content of the mail to have result of the called
> action
> right?
>
> i.e if my actions return list which is iterated on jsp and displayed on
> jsp.
>
> So instead of showing it on browser u want to show it in the content of
> mail???
>
> On Thu, Jul 8, 2010 at 2:10 PM, <ch...@chrismiles.org> wrote:
>
>> Hi.
>>
>> Thanks for the response but that is not what I mean. I want to email the
>> contents of a view - a JSP which has been rendered after an action - but
>> to the contents of an email rather than the contents of a browser
>> request.
>>
>> Chris
>>
>> > If you just want to send mail after some action is executed then
>> >
>> > I think you can do it by using
>> >
>> > action-redirect
>> >
>> > You can redirect the action to send email action.
>> >
>> > Regards,
>> >
>> > Amol Ghotankar
>> >
>> > On Thu, Jul 8, 2010 at 1:08 AM, Chris Miles <ch...@chrismiles.org>
>> wrote:
>> >
>> >> Is it posible for me to render a view after an action and be able to
>> >> access
>> >> the HTML for sending in an email rather than rendering to a browser?
>> >>
>> >> thanks
>> >>
>> >> Chris
>> >
>> >
>> >
>> >
>> > --
>> >
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>
>
> --
>
>
> With Best Regards,
>
> Amol Ghotankar
> Technical Director
> Cursive Technologies Pvt. Ltd.
> 104, A1 Wing, W Sector,
> Masulkar Colony, Ajmera,
> Pimpri, Pune-18 INDIA
> O: +91 2020 270 570
> M: +91 9960 980 419
> www.cursivetech.com
>
>
> CURSIVE TECHNOLOGIES EMAIL NOTICE
> The information contained in this email and any attachments is
> confidential
> and may be subject to copyright or other intellectual property protection.
> If you are not the intended recipient, you are not authorized to use or
> disclose this information, and we request that you notify us by reply mail
> or telephone and delete the original message from your mail system.
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Emailing the contents of a Struts2 view?
Posted by Amol Ghotankar <gh...@gmail.com>.
Hi,
What you want is the content of the mail to have result of the called action
right?
i.e if my actions return list which is iterated on jsp and displayed on jsp.
So instead of showing it on browser u want to show it in the content of
mail???
On Thu, Jul 8, 2010 at 2:10 PM, <ch...@chrismiles.org> wrote:
> Hi.
>
> Thanks for the response but that is not what I mean. I want to email the
> contents of a view - a JSP which has been rendered after an action - but
> to the contents of an email rather than the contents of a browser request.
>
> Chris
>
> > If you just want to send mail after some action is executed then
> >
> > I think you can do it by using
> >
> > action-redirect
> >
> > You can redirect the action to send email action.
> >
> > Regards,
> >
> > Amol Ghotankar
> >
> > On Thu, Jul 8, 2010 at 1:08 AM, Chris Miles <ch...@chrismiles.org>
> wrote:
> >
> >> Is it posible for me to render a view after an action and be able to
> >> access
> >> the HTML for sending in an email rather than rendering to a browser?
> >>
> >> thanks
> >>
> >> Chris
> >
> >
> >
> >
> > --
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
--
With Best Regards,
Amol Ghotankar
Technical Director
Cursive Technologies Pvt. Ltd.
104, A1 Wing, W Sector,
Masulkar Colony, Ajmera,
Pimpri, Pune-18 INDIA
O: +91 2020 270 570
M: +91 9960 980 419
www.cursivetech.com
CURSIVE TECHNOLOGIES EMAIL NOTICE
The information contained in this email and any attachments is confidential
and may be subject to copyright or other intellectual property protection.
If you are not the intended recipient, you are not authorized to use or
disclose this information, and we request that you notify us by reply mail
or telephone and delete the original message from your mail system.
Re: Emailing the contents of a Struts2 view?
Posted by ch...@chrismiles.org.
Hi.
Thanks for the response but that is not what I mean. I want to email the
contents of a view - a JSP which has been rendered after an action - but
to the contents of an email rather than the contents of a browser request.
Chris
> If you just want to send mail after some action is executed then
>
> I think you can do it by using
>
> action-redirect
>
> You can redirect the action to send email action.
>
> Regards,
>
> Amol Ghotankar
>
> On Thu, Jul 8, 2010 at 1:08 AM, Chris Miles <ch...@chrismiles.org> wrote:
>
>> Is it posible for me to render a view after an action and be able to
>> access
>> the HTML for sending in an email rather than rendering to a browser?
>>
>> thanks
>>
>> Chris
>
>
>
>
> --
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Emailing the contents of a Struts2 view?
Posted by Amol Ghotankar <gh...@gmail.com>.
If you just want to send mail after some action is executed then
I think you can do it by using
action-redirect
You can redirect the action to send email action.
Regards,
Amol Ghotankar
On Thu, Jul 8, 2010 at 1:08 AM, Chris Miles <ch...@chrismiles.org> wrote:
> Is it posible for me to render a view after an action and be able to access
> the HTML for sending in an email rather than rendering to a browser?
>
> thanks
>
> Chris
--