0

how to write console based script in zkoss application

asked 2015-10-02 08:17:11 +0800

aliabbas gravatar image aliabbas
1 1

how to write console based script in zkoss application , just like rake application or rake task in rails

Thanks

delete flag offensive retag edit

Comments

do you mean javascript what you want to be executed?

chillworld ( 2015-10-02 08:42:31 +0800 )edit

No 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

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-10-03 11:55:11 +0800

prometeo gravatar image prometeo flag of Italy
43 1 4

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

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2015-10-02 08:17:11 +0800

Seen: 12 times

Last updated: Oct 03 '15

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More