-
FEATURED COMPONENTS
First time here? Check out the FAQ!
how to write console based script in zkoss application , just like rake application or rake task in rails
Thanks
Hello
ZK is for writing UI applications in web fashion.
For running scripts at command line, a bash shell script fits better the target.
I also have to run some cron jobs in my web application.
In this case, I use plain JSP, for example a script page called BatchWorker.jsp in the root directory of my application.
Then call it from cron, for example at 2:15 AM like this:
15 2 * * * root curl -sS http://localhost:8080/MyApp/BatchWorker.jsp
The key for good display on the terminal, or in logs, is to set HttpServletResponse content type and character encoding, like this:
response.setContentType("text/plain");
response.setCharacterEncoding("UTF-8");
For safety reasons, I also check that the requests are from localhost only:
if( !request.getRemoteAddr().equals("0:0:0:0:0:0:0:1") && !request.getRemoteAddr().equals("127.0.0.1") ) {
return;
}
Hope it helps!
Gianluca Bonetti
Prometeo Informatica Italy
Asked: 2015-10-02 08:17:11 +0800
Seen: 17 times
Last updated: Oct 03 '15
do you mean javascript what you want to be executed?
chillworld ( 2015-10-02 08:42:31 +0800 )editNo I dont mean, execute script in terminal, just like I want to update all records , like cron jobs
aliabbas ( 2015-10-02 09:15:07 +0800 )edit