日期:2014-05-18  浏览次数:20723 次

请教:关于 Applet ,servlet,JNI的问题
applet与servlet通信,让后在servlet中使用本地代码,即   JNI,出现错误,调试了好久,还是出错,请各位大侠指教!谢谢!   代码如下:

applet端:

import   java.applet.Applet;
import   java.awt.*;
import   java.awt.event.*;
import   java.io.*;
import   java.net.*;

/**
  *   Simple   demonstration   for   an   Applet   <->   Servlet   communication.
  */
public   class   RobotApplet   extends   Applet   {
private   TextField   inputField   =   new   TextField();
private   TextField   outputField   =   new   TextField();
private   TextArea   exceptionArea   =   new   TextArea();

/**
  *   Setup   the   GUI.
  */
public   void   init()   {
//   set   new   layout
setLayout(new   GridBagLayout());

//   add   title
Label   title   =   new   Label( "监控界面 ",   Label.CENTER);
title.setFont(new   Font( "SansSerif ",   Font.BOLD,   14));
GridBagConstraints   c   =   new   GridBagConstraints();
c.gridwidth   =   GridBagConstraints.REMAINDER;
c.weightx   =   1.0;
c.fill   =   GridBagConstraints.HORIZONTAL;
c.insets   =   new   Insets(5,   5,   5,   5);
add(title,   c);

//   add   input   label,   field   and   send   button
c   =   new   GridBagConstraints();
c.anchor   =   GridBagConstraints.EAST;
add(new   Label( "距离:   ",   Label.RIGHT),   c);
c   =   new   GridBagConstraints();
c.fill   =   GridBagConstraints.HORIZONTAL;
c.weightx   =   1.0;
add(inputField,   c);
Button   sendButton   =   new   Button( "Forward ");
c   =   new   GridBagConstraints();
c.gridwidth   =   GridBagConstraints.REMAINDER;
add(sendButton,   c);
sendButton.addActionListener(new   ActionListener()   {
public   void   actionPerformed(ActionEvent   e)   {
onSendData();
}
});

//   add   output   label   and   non-editable   field
c   =   new   GridBagConstraints();
c.anchor   =   GridBagConstraints.EAST;
add(new   Label( "反馈结果:   ",   Label.RIGHT),   c);
c   =   new   GridBagConstraints();
c.gridwidth   =   GridBagConstraints.REMAINDER;
c.fill   =   GridBagConstraints.HORIZONTAL;
c.weightx   =   50.0;
add(outputField,   c);
outputField.setEditable(false);

//   add   exception   label   and   non-editable   textarea
c   =   new   GridBagConstraints();
c.anchor   =   GridBagConstraints.EAST;
add(new   Label( "异常结果:   ",   Label.RIGHT),   c);
c   =   new   GridBagConstraints();
c.gridwidth   =   GridBagConstraints.REMAINDER;
c.weighty   =   1;
c.fill   =   GridBagConstraints.BOTH;
add(exceptionArea,   c);
exceptionArea.setEditable(false);
}

/**
  * &nbs