当前位置: 代码迷 >> Java Web开发 >> 请问:关于 Applet ,servlet,JNI的有关问题
  详细解决方案

请问:关于 Applet ,servlet,JNI的有关问题

热度:89   发布时间:2016-04-17 14:09:14.0
请教:关于 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);
}

/**
  *   Get   a   connection   to   the   servlet.
  */
private   URLConnection   getServletConnection()
  相关解决方案