I’ve got a spring-application (Spring Roo uses Spring MVC) on a Tomcat-server.
There are some java-files inside the application. One contains a main-method.
I’d like to be able to execute this main-method when I call a URL like http://localhost/execute
How can I map this?
First you need to be able to handle http://localhost/execute request. You can use servlet or spring-mvc. I don’t know Spring Roo, but it most likely has some mechanism to handle HTTP calls (maybe this will help: Spring MVC /Roo – Request method 'GET' not supported).
Once you are able to run arbitrary code on incoming HTTP request, simply call:
or:
insider your servlet/controller/whatever.