File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Applet Serialization Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Applet Serialization" Watch "Applet Serialization" New topic

Applet Serialization

Chandar S Vellithirumutha

Joined: May 29, 2000
Posts: 15
Can any one help me in telling the ways to serialize an applet after creating & painting(drawing graph) the applet. The applet will be passed with parameters with which it has to draw a graph and need to send it as a response.
I am trying to pass some parameter from an HTML which will call a servlet, which needs to send an applet that should be the bar graph of the parameters that i have sent.
(ie) i need to call a servlet xyz with parameter lets say a1=10,a2=20,a3=30..... like
I have the following methods in the applet
class xyzApplet extends Applet {
int parms[];
public void setParameter(int a[]){
parms = a;
public void DrawGraph() {
//take the values of parms[] and draw graph
I am doing the following piece of code in the doGet of servlet
int d[];
d[0] = req.getParameter("Graph1");
xyzApplet x= new xyzApplet();

How do I serialize the painted applet from the servlet. Can any one help me? If you could not understand the question please let me know.
Thanks a bunch
Frank Carver

Joined: Jan 07, 1999
Posts: 6920
It may be that you can do this, but it seems an odd way to work. Most people who use appellets configured by servelets use the following method:
1. A browser form or client program sends a GET or POST request to the servlet with the values as parameters. (you do this; good so far).
2. The servlet builds a HTML response page containing an <APPLET> tag with the parameters listed in <PARAM> elements, and returns it to the browser.
3. The browser fetches the applet and initialises it with the specified parameters.
So in your case of a specific graph display the servlet might recieve parameters a1=10, a2=20, a3=30 etc. and build an HTML reply containing something like the following:

This way, the applet doesn't need to be serialized, and can be cached in the browser and re-used for other graphs later if required.
Have I missed something? Is there some reason why you can't use this model?

Read about me at ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
Chandar S Vellithirumutha

Joined: May 29, 2000
Posts: 15
Thanks Frank. You the man.....
I agree. Here's the link:
subject: Applet Serialization
It's not a secret anymore!