Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending Mail

Status
Not open for further replies.

TexTwil

Programmer
Mar 2, 2004
4
FR
Hi,
i want to send an email in a struts-based application:
I have a SendMailForm form with "Subject" "To" and "Body" fields. Then I have a confirmation page where i display the mail again and the user has to validate. Finally I have a SendMailAction which is supposed to send the mail and then forward to a specific page.

Which is the best way to do the SendMailAction ? I supose i'll have to use JavaMail. Do you think i should write the code directly in the SendMailAction class or write in in other class which will be called by the SendMailAction ?

thanks for you help
 
Hi,

I think it is better to write it as a different class. A helper class which has a static method sendMail() and the action just calls that function.

Coz, tomarrow there might be another requirment where in you might have to send E-Mail from the different action.

It is always good to have helper classes.

Cheers,
Venu
 
Yes,
that's the way i done it.

I have another question. I don't know how handle my confirmation page. Here is what i've done:
My "mail.jsp" page sets up the SendMailForm bean and then simply forwards to the "confirmationEnvoi.jsp" page:

<action name="sendMailForm" forward="/confirmationEnvoi.jsp" validate="true" input="/mail.jsp" scope="session" path="/confirmationEnvoi" />

In this page i take the mail infos from the bean and display them in the page and the user has to validate. The form of this page calls the SendMailAction which is supposed to send the mail:

<action name="sendMailForm" type="fr.gouv.sante.directdh.web.SendMailAction" validate="true" input="/confirmationEnvoi.jsp" scope="session" path="/sendMailAction">

But it doesn't work. I wonder myself if it is possible to have two different action associated woth the same bean.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top