开发者

send commands to a webapp running on tomcat

开发者 https://www.devze.com 2023-04-08 05:59 出处:网络
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 co

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消