title: how to call a .java file in jsp pages?
body: <pre class="lang-html prettyprint-override"><code>&lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1"
      pageEncoding="ISO-8859-1" %&gt;
  
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  
  &lt;html&gt;
  
  &lt;head&gt;
  
  &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;
  
  &lt;title&gt;Insert title here&lt;/title&gt;
  
  &lt;/head&gt;
  
  &lt;body&gt;
  
  &lt;jsp:useBean id="link" class="com.Sshexample"&gt;
  
  &lt;%= link.callconst()%&gt;
  
  &lt;/jsp:useBean&gt;
  
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>I want to call a .java file from jsp. callconst is  a function which is calling the constructor of the class ? I want to call .java file when a button is clicked so I thought of forwarding one jsp to other and another jsp call to .java </p>
  
  <pre><code>  package com;
    import com.jscape.inet.ssh.*; 
    import com.jscape.inet.ssh.util.SshParameters;   
  
    public class Sshexample implements SshListener {  
  
    // state of SSH connection  
    private boolean connected = false;  
  
    /** 
     * Creates a new SshExample instance. 
     * 
     */  
    public Sshexample() {  
       Ssh ssh = null;       
  
       try
         {  
          // create new Ssh instance  
          SshParameters params = new SshParameters("i210","ashishga","Linux_11");  
          System.out.print("Unix server is connected ");  
          ssh = new Ssh(params);  
          // register to capture events  
          ssh.addSshListener(this);  
  
          System.out.println("Connecting please wait...");  
          SshScript script = new SshScript(ssh);  
          SshTask task = new SshTask("$","./call.sh","$");  
  
          // connect  
          script.addTask(task);  
          ssh.connect();  
          while(!script.isComplete()) {  
               Thread.sleep(100);  
              }  
  
          } catch (Exception e) {  
          e.printStackTrace();              
          } finally {  
          try {  
              if(connected) {  
                ssh.disconnect();   
              }  
          } catch(Exception e) {  
  
           }             
        }  
    }  
  
  
    /** 
    * Captures SshConnectedEvent 
    */  
   public void connected(SshConnectedEvent ev) 
   {  
      System.out.println("Connected: " + ev.getHost());  
      connected = true;  
      System.out.println("New ashish is connected to server  "+ ev.getHost());   
  }  
  
  /** 
   * Captures SshDataReceivedEvent 
   */  
  public void dataReceived(SshDataReceivedEvent ev) {  
  
      ev.getData();  
  
  }  
  
  
  /** 
   * Captures SshDisconnectedEvent 
   */  
  public void disconnected(SshDisconnectedEvent ev) {  
  
      System.out.println("ashish server is Disconnecting: " + ev.getHost());  
      connected = false;  
  }  
  
  /* 
   * Main method for SshExample 
   */  
  public void callconst()
  {
     Sshexample t = new Sshexample();
  }
  
  }  
  </code></pre>
  
  <p>ERROR:</p>
  
  <pre><code>javax.servlet.ServletException:
  java.lang.NoClassDefFoundError:                                                            com/jscape/inet/ssh/SshListener
  org.apache.jasper.servlet.JspServlet.service(JspServlet.java:268)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
  </code></pre>