aspose file tools*
The moose likes Applets and the fly likes Applet and Servlet connection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Applet and Servlet connection" Watch "Applet and Servlet connection" New topic
Author

Applet and Servlet connection

bill dimitry
Greenhorn

Joined: May 27, 2008
Posts: 5
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.

Ulf Dittmer
Marshal

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


Ping & DNS - updated with new look and Ping home screen widget
bill dimitry
Greenhorn

Joined: May 27, 2008
Posts: 5
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
Marshal

Joined: Mar 22, 2005
Posts: 39547
    
  27
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".
muthu bharathi
Ranch Hand

Joined: Dec 10, 2008
Posts: 97
Hi,
Can you share your code? im also need this code.....

Thanks in advance..



-- cheers
M. Bharathi
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Applet and Servlet connection
 
Similar Threads
PROBLEMS WITH APPLET -> SERVLET communication
Swing - servlet communication
servlet/applet communication problem
Signed applet talking to server other than its own
Communication between Servlet and Applet