• 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

Applet and Servlet connection

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys,
I've done some testing and my basic code is working. By using a test class I am able to connect to a servlet, get records from a database and print them in the test program. Check this post.
By using the same base classes I am trying to get the DB records into an Applet. The previous test is working fine but now when I try to get data into the Applet I get an error message and a blank applet.
I�ve been using NetBeans 6.1 IDE.

I think that my web app structure is the problem.
Please notice that after every compilation I drag and drop mainApplet.class from web/WEB-INF/classess/ folder to the web folder root.
The best option would be to place mainApplet.class in class/all/ subfolder together with all other classes, but I don�t know how to call it from the jsp page (<APPLET CODE=�mainApplet.class�).
I�ve tried CODE=�all.mainApplet.class� but it doesn�t work.

Thanks,
Bill

NETBEANS SOURCE FOLDER STRUCTURE:
Src/config
Src/java/mainApplet.java
Src/java/all/Course.java
/GetCluster.java

NETBEANS WEB FOLDER STRUCTURE:
Index.jsp // JSP wrapper page
mainApplet.class//Applet class
WEB-INF/classess/all/Course.class//Course object class
/all/GetCluster.class//Servlet class

EROR MESSAGE:
bobo: java.lang.ClassNotFoundException: all.Course
java.lang.ClassNotFoundException: all.Course
at sun.applet.AppletClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at java.io.ObjectInputStream.resolveClass(Unknown Source)
at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
at java.io.ObjectInputStream.readClassDesc(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readArray(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at mainApplet.getRecords(mainApplet.java:350)
at mainApplet.createNodes(mainApplet.java:150)
at mainApplet.buildGraph(mainApplet.java:295)
at mainApplet.init(mainApplet.java:115)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

JSP PAGE CODE:


Here is the Applet code causing the error. The same two methods I've used in the testing class without a problem.

 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

NETBEANS WEB FOLDER STRUCTURE:
mainApplet.class //Applet class
WEB-INF/classess/all/Course.class //Course object class


All applet classes must be publicly accessible, not just the main applet class.
 
bill dimitry
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Ulf,
I've moved all classes on the root level where jsp page is located and it works now.
On Monday I'll keep working on it.
Have a nice weekend.

Kind Regards,
Bill
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
By the way what does "I�ve tried CODE=�all.mainApplet.class� but it doesn�t work" mean? You're right that you should put classes in packages, and generally that works fine. You could try "code=all.mainApplet" instead of "code=all.mainApplet.class".
 
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Can you share your code? im also need this code.....

Thanks in advance..



-- cheers
M. Bharathi
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic