0

I would like to set a time limit for script execution. In PHP I use "set_time_limit". How can I do this in JSP?

Bozho
  • 588,226
  • 146
  • 1,060
  • 1,140
Antoxa
  • 43
  • 2
  • 6

3 Answers3

2

I have to disappoint you - there is no such setting. In JSP it is hardly feasible, when using servlets (especially 3.0) you have some options. However all of them require running your logic in a separate thread.

See my answer here, it is about Spring MVC, but it explains the general concept.

Community
  • 1
  • 1
Tomasz Nurkiewicz
  • 334,321
  • 69
  • 703
  • 674
0

Wrap the code you want to execute inside of java Runnable, then use ExecutorService to set a timeout for that task.

http://download.oracle.com/javase/1,5,0/docs/api/java/lang/Runnable.html http://download.oracle.com/javase/6/docs/api/java/util/concurrent/ExecutorService.html

Hardip Singh
  • 126
  • 4
0

This should be a setting of your servlet container. In tomcat you can configure these on the connector - see here (look for 'timeout'). (Also see here)

Bozho
  • 588,226
  • 146
  • 1,060
  • 1,140