简体   繁体   English

从JSP脚本标签调用Java函数

[英]Invoking a java function from JSP Script tag

I have a JSP file as below 我有一个JSP文件,如下所示

<SCRIPT>
function validateEvent(){
 // I want to call Java function myProfile() here
 }
 </SCRIPT>

 <html:select property="event" styleClass="input"   onchange="validateEvent();">
  </html:select>

All I want to do is, call the java function myProfile() from validateEvent() function, that gets triggered on change of the value in event dropdown. 我要做的就是从validateEvent()函数调用java函数myProfile(),该事件在事件下拉列表中的值更改时触发。 Any help in this regard would be greatly appreciated. 在这方面的任何帮助将不胜感激。

You can't use a <script> tag to execute a java method server-side from the client. 您不能使用<script>标记从客户端在服务器端执行Java方法。 Those tags corresponds to Javascript, which is executed on the client side, and therefore it doesn't have access to what's going on on your server directly. 这些标记对应于Javascript,该Javascript在客户端执行,因此它无法直接访问服务器上正在发生的事情。

If you need to retrieve information from your server, have a look at something called AJAX. 如果需要从服务器检索信息,请查看称为AJAX的内容。

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

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