• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Applet Serialization

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
http://127.0.0.1:8080/examples/servlet/graph?a1=10&a2=20&a3=3....
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();
x.setParameter(d);
x.paint(x.getGraphics());
...
}

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
Chandar
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Chandar S Vellithirumutha
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Frank. You the man.....
 
You ought to ventilate your mind and let the cobwebs out of it. Use this cup to catch the tiny ads:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic