aspose file tools*
The moose likes JSP and the fly likes Create a cron job which sends an email alert when a certain condition is satisfied Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Create a cron job which sends an email alert when a certain condition is satisfied " Watch "Create a cron job which sends an email alert when a certain condition is satisfied " New topic
Author

Create a cron job which sends an email alert when a certain condition is satisfied

Chaitra Kear
Greenhorn

Joined: Nov 05, 2012
Posts: 7
I have a backend MySQL database which keeps track of the number of invalid accesses to a file on a web server(I am new to the use of cron jobs though)I want an email to be sent to the file owner when the number of accesses exceed a certain number.Could anyone please suggest how this could be done using JSP?
Thanks in advance.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61433
    
  67

JSP does not seem like a suitable technology to use for this purpose. Why do you want to use JSP for this?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Chaitra Kear
Greenhorn

Joined: Nov 05, 2012
Posts: 7
Well, I heard a sever side scripting language like PHP could get the job done.
Since my web application uses JSP at the front end,wanted to know if it could do the same.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61433
    
  67

First of all, your post doesn't make it sound like the email will be sent from the web application, but as part of the cron job. So it's not even part of the web app.

Also, JSP is well suited to serving as a template for responses, but not so much for general-purpose templating.

For that, most people would use a more general-purpose templating tool such as FreeMarker.
Chaitra Kear
Greenhorn

Joined: Nov 05, 2012
Posts: 7
Ok, suppose I make use of MySQL triggers instead of the cron job,then will it be possible?The app has been coded up in netbeans,so I don't understand how an external tool can be used here.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61433
    
  67

Chaitra Kear wrote:Ok, suppose I make use of MySQL triggers instead of the cron job,then will it be possible?

Triggers has nothing at all to do with JSP. Again, you are barking up the wrong tree. I don't think JSP is the right tool for the job.

The app has been coded up in netbeans,so I don't understand how an external tool can be used here.

So what? Netbeans is an editor. What does it have to do with the ability to use "external tools"?
Chaitra Kear
Greenhorn

Joined: Nov 05, 2012
Posts: 7
Oh got it, FreeMarker can be used as a NetBeans plugin.I am so naive, and i admit it.
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30764
    
156

Freemarker is a library (jar). NetBeans (and all other IDEs) let you add jars to your classpath. You could also use a Freemarker plugin to make you editing easier. But that's independent of getting the jar itself.

I question whether you even need Freemarker. Unless your email is complicated, you might just concatenate strings to compose the email. It's a minor part of the problem - just for the formatting part.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Chaitra Kear
Greenhorn

Joined: Nov 05, 2012
Posts: 7
As you said, I don't think I need FreeMarker at all, because my email isn't going to be complicated(just a fixed message to reset their password).However MySQL by itself cannot send the email I believe.There were suggestions on the net to make the trigger run an external script(written in PHP ) which does this.And there's this JavaMail API,which also comes to my mind.I am confused as to what to use now.Thank you.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61433
    
  67

Chaitra Kear wrote:As you said, I don't think I need FreeMarker at all, because my email isn't going to be complicated

Then why did you feel you needed JSP? I assumed it was because you needed templating for the email body.

However MySQL by itself cannot send the email I believe.There were suggestions on the net to make the trigger run an external script(written in PHP ) which does this

If this is a cron job, why not just do it from the shell? If you don't need templating, you could likely just use the mail shell command. (Or is this running on Windows? I assume not.)

And there's this JavaMail API

That's what you would use if you were to do this from Java.

 
 
subject: Create a cron job which sends an email alert when a certain condition is satisfied