Hi All,

I have written a JSP file which will run query, get the result in a csv file and send the csv file daily to an email address. But how can I execute this JSP file daily in Linux? Can anyone help in this?

Recommended Answers

All 10 Replies

By writing a stand-alone application to do this and using a cron-job to "run it daily". A JSP is not the right tool for this task and it never was. Use the right tool for the task.

If JSP is not the right tool for this task, can you tell me which is the right tool for this task?
Thanks

If JSP is not the right tool for this task, can you tell me which is the right tool for this task?
Thanks

a stand-alone application ... and ... a cron-job

regardless of the language in which the app is written in. Java, C/C++, perl, even a shell script.

can we write links in cron.daily?I have read that u can write a link in cron.daily?

What link? There is no need for a link. What the heck do you need a link for? Like I said (and quoted), write an application (a stand-alone command line application not a JSP) that performs the actions that you currently have this JSP doing (which is wrong anyway, a JSP should do nothing but deliver HTML) and use cron to execute that application. How is it so hard to understand that?

And you are still in the wrong. This entire "setup" is so far out of whack it's not even funny anymore. Oh well, whatever works. You can also jam a knife into your eye in order to scratch the back of your head, but is it worth it?

As you ask me what link,I understand that you do not know how to give a link for a cron.daily job

You said :-

can we write links in cron.daily?I have read that u can write a link in cron.daily?

So definitely he asked what link.

And next you are not exactly invoking a link, you are feeding the link to 'links' a text based browser which is doing the job of invoking the link of your JSP for you.

What masijade said and I concur is this is not a job for a JSP, covert it to a Java application (since then you can reuse the code), and run that Java application via cron.

I used http://jtheory.com/jdring.html
Put cron like job in servlet.
web.xml:

<servlet>
		<servlet-name>Cron</servlet-name>
		<servlet-class>com.my.hrit.servlet.Cron</servlet-class>
		<load-on-startup>1</load-on-startup>
	</servlet>

Following code in servlet init():

// run every day at 6:50 PM
			mgr.addAlarm("ComplexCron2", 50, 18, -1, -1, -1, -1,
					new AlarmListener() {
						public void handleAlarm(AlarmEntry entry) {
							System.out.println("\u0007Cron alarm1 ("
									+ new Date() + ")");


						}

					});

I put my cron like servlet at It works great.

And still the wrong tool for the job, but I think I'm finished talking to the walls now.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.