0

I need to execute a jsp page after every 30 minutes. I am using glassfish server. I want to uses cron job for that, but I never work before with cron job.

Please give me any link or example from where I can understand how to configure a cron job for jsp page and execute it after a specific time period?

thanks in advance, Enamul

ehp
  • 2,495
  • 6
  • 29
  • 43
  • possible duplicate of [Background timer task in JSP/Servlet web application](http://stackoverflow.com/questions/5357033/background-timer-task-in-jsp-servlet-web-application) By the way, you need to redesign your JSP page first. [JSP](http://stackoverflow.com/tags/jsp/info) is intented to generate HTML, [not](http://stackoverflow.com/questions/3177733/how-to-avoid-java-code-in-jsp-files) to run business code. – BalusC Jun 03 '12 at 04:02
  • What does "execute a jsp page" mean here? Do you want to send it an HTTP GET/POST request? What do you want to do with the output? – Jim Garrison Jun 03 '12 at 04:03
  • i want to check the database after a specific time that any new row is inserted or not. if yes than I need to create a csv file and insert those new rows into tha csv file. – ehp Jun 03 '12 at 05:20
  • Sounds like you just want a background process, not a JSP. – Jim Garrison Jun 03 '12 at 07:00
  • yeah, it's like background process and I want use JSP for that. – ehp Jun 03 '12 at 08:02

1 Answers1

1

If you simply want to cause the webserver to "execute" a JSP page, you need to send the webserver a suitable HTTP request. The simplest way to do this is to use a command line tool like wget or curl (or the Windoze alternatives). Once you can do that successfully, it is a simple matter to turn that into a cron job.

Refer to:

  • The documentation of your webserver / webapp to find out what URL to use, the HTTP method type to use, what parameters to send, and so on.
  • The manual entry for wget(1) or curl(1) for how to use these commands.
  • The manual entries for crontab(1) and crontab(5) to find out how to create a cron job.

Trying to do this in Java is most likely going to make the task more complicated than it needs to be.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216