Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Applet Serialization  RSS feed

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • 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: 6920
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Thanks Frank. You the man.....
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!