简体   繁体   English

将命令发送到在Tomcat上运行的Web应用程序

[英]send commands to a webapp running on tomcat

I'm new with java and tomcat, so, excuse me if it's silly. 我是java和tomcat的新手,所以,如果很傻,请原谅。

I would like to send commands (from the console) to a servlet that is already running on tomcat. 我想将命令(从控制台)发送到已经在tomcat上运行的servlet。 The webapp will run the command in the tomcat context and return the appropiate answer. 该webapp将在tomcat上下文中运行该命令,并返回适当的答案。

ie: 即:

$ 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. 您可以使用curlwget类的工具从命令行向Servlet发出HTTP GET(或POST)请求,然后处理Servlet的响应。 Advantage: If properly set up, you can run those commands also from a remote location. 优点:如果设置正确,您也可以从远程位置运行这些命令。

是的,您可以使用curlwget等几种命令行工具来调用servlet并获取响应。

and if you want to more than simple, you can make a simple program that communicate with servlet by HTTP Post or GET request. 如果您不仅仅想简单,还可以制作一个简单的程序,该程序可以通过HTTP Post或GET请求与servlet进行通信。 The key is : 关键是:

How to communicate with servlet, we can use several http method and any other protocol. 如何与servlet通信,我们可以使用几种http方法和任何其他协议。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM