wood burning stoves 2.0*
The moose likes Servlets and the fly likes where to put the object passed betweeb servlet and applet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "where to put the object passed betweeb servlet and applet" Watch "where to put the object passed betweeb servlet and applet" New topic
Author

where to put the object passed betweeb servlet and applet

may Lee
Ranch Hand

Joined: Nov 20, 2003
Posts: 68
I have Redhat 9:

Tomcat is able to run at: http://local/exapples, no need http://localhost:8080/examples

Apache web server is running, the home folder is /usr/www/html/

I want to pass a object(my own class) between applet and a servlet. First the Applet passes the opject to Servlet with some parameters, then servlet receives this object and change some data inside the object and pass it back to applet.

My applet is under Apache web server home folder.
My servlet is under $CATALINA_HOME/webapps/examples/ (I am using webapp to connect Applet and servlet)
Now, where shall I put my class, the object passed between applet and servlet? It should be a class like the normal Java public class. I have serialized this object. like the followings:

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;

class dataStructure implements java.io.Serializable{
int dy,dm;

dataStructure(int arg1){
dy=arg1;
dm=0;
}

}

Please any advise!
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
If the servlet is to deserialize the object, it must be able to locate the class file. If the servlet lives in /examples, one place you could put the class file is /examples/WEB-INF/classes/yourpackage/dataStructure.class
(your class MUST be in a package)
Naturally the applet must also be able to load the class, but this can't be done from the WEB-INF hierarchy so the class file must also appear where the browser can get it.
See the Tomcat documentation for where to locate classes that need to be visible from more than just one web application.
Bill
may Lee
Ranch Hand

Joined: Nov 20, 2003
Posts: 68
If I put my package in the public Java home, then import my class both in Servlet and Applet, it sould work even my applet and servlet are in other two different folder?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: where to put the object passed betweeb servlet and applet
 
Similar Threads
where to put oeject passed between applet and servlet
unable to compile
Cookies on Tomcat and Apache JServ
How to deploy a Web Application in Apache Tomcat?
again, the class object passed between applet and servlet