struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul-J Woodward" <>
Subject RE: sending emails from a struts app
Date Tue, 18 May 2004 16:44:15 GMT
Simply make your action servlet spawn a thread to perform the action/send 
the mail atomically. The easiest way is to make your mail sending class 
extend the Thread class, create a new instance and run it.

Global Equity Derivatives Technology
Deutsche Bank [/]

"Daniel Perry" <>
18/05/2004 17:36
Please respond to "Struts Users Mailing List"

        To:     "Struts Users Mailing List" <>
        Subject:        RE: sending emails from a struts app

JavaMail - no problem... found loads of examples.

With regards to the canceling of requests, i'm not sure what you're saying 
are you saying
1. your code will stop on browser cancels and there's nothing you can do
2. you're code will always finish running even if the user cancels (tho
obviously it wont get displayed)

Comparing this to php, when a browser cancels a request to php, it stops 
execution of the script (sometimes...). But, you can add code to make the
script complete regardless of wether the user is still there or not.

This is what i want to acheive.  I cant have the user submitting a 
and then stopping it part way through.


-----Original Message-----
From: James Mitchell []
Sent: 18 May 2004 17:32
To: Struts Users Mailing List
Subject: Re: sending emails from a struts app

> I need to send out emails from a struts app.
> Any comments on the best way to go about this?

Yes, use JavaMail:

> As sending mail can be slow, is there an easy way to do this in the
> background?

That depends entirely on your requirements.  I supposed you could use
anything from kicking off another thread [0] to using JMS [1] to queue
up some mail process.


> What happens if a client cancels a request part way through? is there 
> way to handle this / ignore cancels?

"part way through".....there's no such animal.   Once the page is 
or a link is clicked, you (server side) have no control over it.  At best,
the browser may send a disconnect if the user hits the stop button or 
the browser abruptly, but that's not guaranteed and is VERY browser
Even if you were lucky enough to dictate the browser and version, you will
never see it get past the container.  As I have told other people, I would
give up on that requirement, unless you want to "roll your own browser" 
my current gig is doing[3].


James Mitchell
Software Engineer / Open Source Evangelist
AIM: jmitchtx

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message