你的要求不可能实现,在jsp中能调用,在存html里不可能,js里面也不可以吧。
jsp里面的调用是这样的,希望对你有用。
<%@ page import="Converter,ConverterHome,javax.ejb.*, java.math.*, javax.naming.*, javax.rmi.PortableRemoteObject, java.rmi.RemoteException" %>
<%!
   private Converter converter = null;   public void jspInit() { 
      try {
         InitialContext ic = new InitialContext();
         Object objRef = ic.lookup("java:comp/env/ejb/TheConverter");
         ConverterHome home = (ConverterHome)PortableRemoteObject.narrow(objRef, ConverterHome.class);
         converter = home.create();
      } catch (RemoteException ex) {
            System.out.println("Couldn't create converter bean."+ ex.getMessage());
      } catch (CreateException ex) {
            System.out.println("Couldn't create converter bean."+ ex.getMessage());
      } catch (NamingException ex) {
            System.out.println("Unable to lookup home: "+ "TheConverter "+ ex.getMessage());
      } 
   }   public void jspDestroy() {    
         converter = null;
   }
%>
<html>
<head>
    <title>Converter</title>
</head><body bgcolor="white">
<h1><b><center>Converter</center></b></h1>
<hr>
<p>Enter an amount to convert:</p>
<form method="get">
<input type="text" name="amount" size="25">
<br>
<p>
<input type="submit" value="Submit">
<input type="reset" value="Reset">
</form><%
    String amount = request.getParameter("amount");
    if ( amount != null && amount.length() > 0 ) {
       BigDecimal d = new BigDecimal (amount);
%>
   <p>
   <%= amount %> dollars are  <%= converter.dollarToYen(d) %>  Yen.
   <p>
   <%= amount %> Yen are <%= converter.yenToEuro(d) %>  Euro.
<%
    }
%></body>
</html>

解决方案 »

  1.   

    你可以写一个Javabean,用一个方法来调用sessionbean中的add方法,然后在jsp中将input的结果在submit之后提交到javabean中,即可!
    在javabean中调用sessionbean的代码:
    例如有一个javabean是GetData
    有一个SessionBean是mySession
      public GetData() {//构造器
        try {
          Context ctx = new InitialContext();
          Object ref = ctx.lookup("mySession");
          mySessionHome = (MySessionHome) PortableRemoteObject.narrow(ref, MySessionHome.class);
          mySession=mySessionHome.create();
        }
        catch(Exception e) {
          e.printStackTrace();
        }
      }
    之后用mySession就可以调用sessionbean的方法了!