I'm new with java and tomcat, so, excuse me if it's silly.
I would like to send commands (from the console) to a servlet that is already runni开发者_JAVA技巧ng on tomcat. The webapp will run the command in the tomcat context and return the appropiate answer.
i.e:
$ consoleApp status
running
Is it possible?, if yes, how?
thanks in advance.
You can make HTTP GET (or POST) requests to your servlet from the command line using tools like curl
or wget
and then process the servlet's response. Advantage: If properly set up, you can run those commands also from a remote location.
Yes, you can use several command line tools such as curl
or wget
to call your servlet and obtain the response.
and if you want to more than simple, you can make a simple program that communicate with servlet by HTTP Post or GET request. The key is :
How to communicate with servlet, we can use several http method and any other protocol.
精彩评论