• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Calling applet which loads JasperPrint from jsp

 
Mira Suting
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a similar problem which many are facing. I tried my best but I'm not able to solve it.

I have an applet class

package in.support.reports;

public class AppletTrial extends JApplet{

public void getviewer(JasperPrint jasprint){
//JasperPrint jasprint = (JasperPrint)request.getAttribute("jasprint");
JRViewer aViewer = new JRViewer(jasprint);
JFrame aFrame = new JFrame("Report Viewer");
aFrame.getContentPane().add(aViewer);
java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
aFrame.setSize(screenSize.width/2, screenSize.height/2);
java.awt.Insets insets = aFrame.getInsets();
aFrame.setSize(aFrame.getWidth() + insets.left + insets.right, aFrame.getHeight() + insets.top + insets.bottom + 20);
aFrame.setLocation((screenSize.width-aFrame.getWidth())/2,(screenSize.height-aFrame.getHeight())/2);
aFrame.show();
}
}

this works fine. I want to call this same file in jsp(D:\workspace\projectName\web\reports\reports.jsp) using

<jsp:plugin type="applet" codebase="D:\workspace\projectName\build\web\WEB-INF\classes\in\support\reports" code="AppletTrial"
width="400" height="400">
<jsp:fallback>
<p>Unable to load applet</p>
</jsp:fallback>
</jsp:plugin>

Java Console gives me the following error:

java.lang.NoClassDefFoundError: AppletTrial (wrong name: in/support/reports/AppletTrial)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
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)
Exception: java.lang.NoClassDefFoundError: AppletTrial (wrong name: in/support/reports/AppletTrial)



Kindly help me. I really need help

Thanks
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The codebase attribute should not contain the directories that make up the package hierarchy; in this case it should be "D:\workspace\projectName\build\web\WEB-INF\classes".

I strongly recommend that you don't use absolute paths in this attribute, and also that you get into the habit of putting applet files outside of WEB-INF; otherwise this will only work on your local machine, but not anywhere else.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic