This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Calling applet which loads JasperPrint  from jsp" Watch "Calling applet which loads JasperPrint  from jsp" New topic
Author

Calling applet which loads JasperPrint from jsp

Mira Suting
Greenhorn

Joined: Aug 13, 2009
Posts: 2
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
Marshal

Joined: Mar 22, 2005
Posts: 41599
    
  55
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.


Ping & DNS - my free Android networking tools app
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Calling applet which loads JasperPrint from jsp