Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Chaitra Kear
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64185
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSP does not seem like a suitable technology to use for this purpose. Why do you want to use JSP for this?
 
Chaitra Kear
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64185
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64185
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 33694
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Chaitra Kear
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64185
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic