从外部运行程序获取字符串
我有带有文本字段和按钮的 jsp 页面。我还有另一个项目的罐子。 当我单击按钮时,将调用 jar 的 MAIN.class 并且程序在独立窗口(JFrame)中运行。 用户完成程序并退出后,我需要获取退出时生成的程序字符串并将其粘贴到文本框中(该字符串是 HTML 代码)
还有其他人遇到此问题并有解决方案吗? 谢谢 亚历克斯
I have jsp page with text field and button. Also i have jar of another project.
When i click on the button the MAIN.class of the jar is called and program is running in independent window(JFrame).
After user is finished with the program and exits, I need to get the String of program that is generated on exit and paste it into the textbox (The String is HTML code)
Is anyone else having this problem and has a solution?
Thanks
Alex
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您的“来自另一个项目的 jar”将其输出打印到标准输出。您可以使用下面的代码在 servlet 中获取输出。
If your "jar from another project" prints its output to standart output. You can use below code to take output in your servlet.
这在生产环境中永远行不通。 Java 代码在 Web 服务器(服务器端)执行,HTML 代码在 Web 浏览器(客户端)执行。基本上,Swing 的东西只会在网络服务器上执行,而不是在网络浏览器上执行。仅当网络服务器和网络浏览器同时在同一台计算机上运行时(就像您在本地开发时一样),它才会起作用。
将其包装在与 HTTP servlet 通信的 Applet 中,或者只是转换 Swing内容转换为 HTML,这样您就无需为此烦恼。
This ain't ever going to work in a production environment. Java code is executed at webserver (server side) and HTML code is executed at webbrowser (client side). Basically, that Swing thing would only be executed at the webserver, not at the webbrowser. It would only work when both the webserver and webbrowser runs by coincidence at physically the same machine (like as when you're developing locally).
Wrap it in an Applet which communicates to a HTTP servlet or just transform the Swing thing to HTML so that you don't need to hassle with that.