• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Calling applet which loads JasperPrint from jsp

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic