简体   繁体   English

我如何从JSP调用C ++函数

[英]How do i call C++ function from a JSP

I have called C++ function from Java by using Java Native interface, but now I want to use these java native interface in JSP. 我已经使用Java本机接口从Java调用了C ++函数,但是现在我想在JSP中使用这些Java本机接口。 So how to use java native interface in a java web project? 那么如何在Java Web项目中使用Java本机接口呢?

You don't. 你不知道 JSPs are for templating, not calling code. JSP用于模板,而不是调用代码。 Keep your business logic elsewhere, and pass the result along in a session variable you can pull out with JSTL. 将您的业务逻辑保留在其他位置,并将结果传递到可以使用JSTL提取的会话变量中。

If you absolutely insist on doing it from a JSP, scriptlets are really just Java code, anyway. 如果您绝对坚持要通过JSP进行操作,那么无论如何,脚本集实际上只是Java代码。 The fact that this is JNI (since you've already got that working) is irrelevant. 这是JNI(因为您已经可以使用它了)这一事实是无关紧要的。 You just have some Java interface you're interacting with. 您只有一些要与之交互的Java接口。

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

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