File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes Calling applet which loads JasperPrint  from jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Badass: Making Users Awesome this week in the Game Development forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Calling applet which loads JasperPrint  from jsp" Watch "Calling applet which loads JasperPrint  from jsp" New topic

Calling applet which loads JasperPrint from jsp

Mira Suting

Joined: Aug 13, 2009
Posts: 2

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


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");
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.bottom + 20);

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">
<p>Unable to load applet</p>

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 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$ Source)
at Source)
Exception: java.lang.NoClassDefFoundError: AppletTrial (wrong name: in/support/reports/AppletTrial)

Kindly help me. I really need help

Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42954
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.
I agree. Here's the link:
subject: Calling applet which loads JasperPrint from jsp