NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

Exception displaying a JApplet on a JSF 2.0 webapp

 
Post new topic   Reply to topic    NetBeans Forums -> Java EE Users
View previous topic :: View next topic  
Author Message
pepelara



Joined: 29 Nov 2008
Posts: 115

PostPosted: Sun Jan 30, 2011 11:14 am    Post subject: Exception displaying a JApplet on a JSF 2.0 webapp Reply with quote

Hi I have been studying the NB tutorial about Applets at,
http://netbeans.org/kb/docs/web/applets.html#embed

But this is not my case. What I have is a package chat with the Japplet Chat.java.
I call the JApplet to be displayed in a JSP file chatTR.jsp as follows,

<%@page ([email]%@page[/email]) contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<%
String path = request.getContextPath();
%>
<applet code="chat.Chat"
codebase="<%= path %>"
height="400" width="300">
<param name="user" value="TR">
</applet>
</body>
</html>

The JApplet Chat.java is as follows,

package chat;

import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.FlowLayout;
import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;

public class Chat extends JApplet {

JTextArea jTA;
JTextField jTF;
JButton jB;
JCheckBox jcbTR;
JCheckBox jcbET;
JCheckBox jcbPP;
/**
* Initialization method that will be called after the applet is loaded
* into the browser.
*/
public void init() {
// TODO start asynchronous download of heavy resources
String user = getParameter("user");

Container contentPane = getContentPane();
BorderLayout blMain = new BorderLayout();

JPanel jpMain = new JPanel();
jpMain.setLayout(new FlowLayout());
jTA = new JTextArea(10, 5);
jpMain.add(jTA);
blMain.addLayoutComponent(jpMain, BorderLayout.CENTER);

JPanel jpControls = new JPanel();
BorderLayout blControls = new BorderLayout();

JPanel jpTextField = new JPanel();
jpTextField.setLayout(new FlowLayout());
jTF = new JTextField(5);
jpTextField.add(jTF);
jB = new JButton("Send");
jpTextField.add(jB);
blControls.addLayoutComponent(jpTextField, BorderLayout.CENTER);

JPanel jpCheckBox = new JPanel();
jpCheckBox.setLayout(new FlowLayout());
jcbTR = new JCheckBox();
jcbTR.setText("TR");
jcbET = new JCheckBox();
jcbET.setText("ET");
jcbPP = new JCheckBox();
jcbPP.setText("PP");
jpCheckBox.add(jcbTR);
jpCheckBox.add(jcbET);
jpCheckBox.add(jcbPP);
if(user.equals("TR")){
jcbTR.setSelected(true);
jcbTR.setEnabled(false);
}
if(user.equals("ET")){
jcbET.setSelected(true);
jcbET.setEnabled(false);
}
if(user.equals("PP")){
jcbPP.setSelected(true);
jcbPP.setEnabled(false);
}
blControls.addLayoutComponent(jpCheckBox, BorderLayout.SOUTH);

blMain.addLayoutComponent(jpControls, BorderLayout.SOUTH);

contentPane.setLayout(blMain);
}

// TODO overwrite start(), stop() and destroy() methods

@Override
public void start() {
}

@Override
public void stop() {
}

@Override
public void destroy() {
}
}

But I get the following exception,

load: class chat.Chat not found.
java.lang.ClassNotFoundException: chat.Chat
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: open HTTP connection failed:http://localhost:8081/Workflow/chat/Chat.class
at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader.access$000(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
... 7 more
Excepci
Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> Java EE Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo