Problem in launch Applet with Browser on Tomcat. [message #1832133] |
Wed, 09 September 2020 19:05  |
Eclipse User |
|
|
|
Dear experts,
I have a very simple Applet, and html file, I can run it with appletviewer, but when I run the html on Tomcat with Firefox/Chrome; http://localhost:8080/openapplet1.html, i got an empty page-- no color, no border, and no error.
tomcat version: apache-tomcat-8.5.31 ,JRE 1.8.0_171. I can run http://localhost:8080. Both Applet and html file are put in ROOT folder. I tried also creating "classes" folder under WEB-INF, and put the class file there.
My code are: (jdk1.8.0_171)
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.net.*;
public class openapplet1 extends Applet implements ActionListener {
private static final long serialVersionUID = 3388464579234129L;
Button btngo;
TextField txtUrl;
public void init() {
btngo = new Button("GO");
txtUrl = new TextField("Enter url here");
add (btngo);
add (txtUrl);
btngo.addActionListener(this);
}
public void actionPerformed(ActionEvent ae) {
try {
URL url= new URL("http://www.goog.com"); //" +txtUrl.getText()+"");
System.out.println(url.toString());
}catch(Exception e) {
e.printStackTrace();
}
}
}
--------------------------
<html>
<head>
<title>Applet Web</title>
</head>
<body>
<applet code="openapplet1.class" height="300" width="400">
</applet>
</body>
</html>
Please help.
Thanks,
Eric
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03420 seconds