Hello ,
Even I faced the same problem . You can use ObjectStream to do the
communication . I have this snippet .
**********CODE AT APPLET SIDE *************
Vector vec= new Vector();
vec.addElement("AAAA");
vec.addElement("BBBB");
vec.addElement("CCCC");
URL base = getCodeBase();
URL lnk = new URL("YOUR_SERVLET_URL");
URLConnection uc = lnk.openConnection();
uc.setDoOutput(true);
uc.setDoInput(true);
uc.setUseCaches(false);
uc.setRequestProperty("Content-type","application/x-www-form-urlencoded");
ObjectOutputStream dos = new ObjectOutputStream(uc.getOutputStream());
dos.writeObject(vec);
ObjectInputStream ois = new ObjectInputStream(uc.getInputStream());
Vector vec_rcd = (Vector) ois.readObject();
dos.flush();
dos.close();
****** CODE AT SERVER SIDE ****************
Vecor vv1=null;
try
{
ObjectInputStream ois = new ObjectInputStream(req.getInputStream());
vv1 = (Vector) ois.readObject();//Here it receives Vector obj sent by
Applet
}
catch(Exception ee1)
{
System.out.println("There is an Exception in getting the OBJECT from the
APPLET:"+ee1.toString());
}
//do some operation add 2 more elements
vv1.addElement("XXXX");
vv1.addElement("YYYY");
//sending back vector obj back to Applet
ObjectOutputStream dos = new ObjectOutputStream(resp.getOutputStream());
dos.writeObject(vv1);
hope this would help you .
Anant Sagar
----- Original Message -----
From: "[Peter Thomsen]" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, February 20, 2002 4:53 PM
Subject: Re: get data from servlets to applet and vice versa
> hi
>
> Sun have a quite ok article on applet/servlet communication. You can find
it under technical articles - servlets and serialization or something like
that.
>
> Hope you find what you are looking for.
>
> Peter
>
>
> Oprindelig besked :
>
> > hi,
>
> >
> > try this way.
> > get the data from the database and set it into some collection
objects.
> > this part will be taken care by the controller.
> >
> > if u r using JSPs, then pass the control to this JSP where in u can
collect
> > the data from the collection objects and
> > and pass it as PARAM to APPLET.
> > in the applet collect all the PARAM
> > this will ensure dynamic parameters..
> >
> > hope that helps
> >
> > Rohan
> >
> >
> >
> > -----Original Message-----
> > From: Ma. Irma G. Ambrocio [mailto:[EMAIL PROTECTED]]
> > Sent: Wednesday, February 20, 2002 2:49 PM
> > To: [EMAIL PROTECTED]
> > Subject: get data from servlets to applet and vice versa
> >
> >
> > i have to generate a graph using applet but the statistics i need is in
a
> > database so i have to use servlets.
> > but i have no idea how to pass data from servlet to applet.
> > HELP!!!
> >
> >
> >
> > DISCLAIMER: Information contained and transmitted by this E-MAIL is
> > proprietary to MASCOT SYSTEMS LTD and is intended for use only by the
> > individual or entity to which it is addressed, and may contain
information
> > that is privileged, confidential or exempt from disclosure under
applicable
> > law. If this is a forwarded message, the content of this E-MAIL may not
have
> > been sent with the authority of the Company. If you are not the intended
> > recipient, an agent of the intended recipient or a person responsible
for
> > delivering the information to the named recipient, you are notified that
any
> > use, distribution, transmission, printing, copying or dissemination of
this
> > information in any way or in any manner is strictly prohibited. If you
have
> > received this communication in error, please delete this mail & notify
us
> > immediately at [EMAIL PROTECTED] Before opening attachments,
> > please scan for viruses
> >
> >
> >
> -------------------------
> > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
>
> > <HTML><HEAD>
> > <META HTTP-EQUIV="Content-Type" CONTENT="text/html; >
charset=iso-8859-1">
> >
> >
> > <META content="MSHTML 5.50.4134.600" name=GENERATOR>
> > <STYLE></STYLE>
> > </HEAD>
> > <BODY bgColor=#ffffff>
> > <DIV><FONT face=Arial color=#0000ff size=2><SPAN
> > class=169433810-20022002>hi,</SPAN></FONT></DIV>
> > <DIV><FONT face=Arial color=#0000ff size=2><SPAN
> > class=169433810-20022002></SPAN></FONT> </DIV>
> > <DIV><FONT face=Arial color=#0000ff size=2><SPAN
> > class=169433810-20022002> try this > way.</SPAN></FONT></DIV>
> > <DIV><FONT face=Arial color=#0000ff size=2><SPAN
> > class=169433810-20022002> get the data from the > database and
> > set it into some collection objects.</SPAN></FONT></DIV>
> > <DIV><FONT face=Arial color=#0000ff size=2><SPAN >
class=169433810-20022002>this
> > part will be taken care by the controller.</SPAN></FONT></DIV>
> > <DIV><FONT face=Arial color=#0000ff size=2><SPAN
> > class=169433810-20022002> </SPAN></FONT></DIV>
> > <DIV><FONT face=Arial color=#0000ff size=2><SPAN >
class=169433810-20022002>if u r
> > using JSPs, then pass the control to this JSP where in u can collect >
the data
> > from the collection objects and </SPAN></FONT></DIV>
> > <DIV><FONT face=Arial color=#0000ff size=2><SPAN >
class=169433810-20022002>and
> > pass it as PARAM to APPLET.</SPAN></FONT></DIV>
> > <DIV><FONT face=Arial color=#0000ff size=2><SPAN >
class=169433810-20022002>in the
> > applet collect all the PARAM </SPAN></FONT></DIV>
> > <DIV><FONT face=Arial color=#0000ff size=2><SPAN
> > class=169433810-20022002> this will ensure dynamic
> > parameters..</SPAN></FONT></DIV>
> > <DIV><FONT face=Arial color=#0000ff size=2><SPAN
> > class=169433810-20022002></SPAN></FONT> </DIV>
> > <DIV><FONT face=Arial color=#0000ff size=2><SPAN >
class=169433810-20022002>hope
> > that helps</SPAN></FONT></DIV>
> > <DIV><FONT face=Arial color=#0000ff size=2><SPAN
> > class=169433810-20022002></SPAN></FONT> </DIV>
> > <DIV><FONT face=Arial color=#0000ff size=2><SPAN
> > class=169433810-20022002>Rohan</SPAN></FONT></DIV>
> > <DIV><FONT face=Arial color=#0000ff size=2><SPAN
> > class=169433810-20022002></SPAN></FONT> </DIV>
> > <DIV><FONT face=Arial color=#0000ff size=2><SPAN
> > class=169433810-20022002></SPAN></FONT> </DIV>
> > <BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
> > <DIV class=OutlookMessageHeader dir=ltr align=left><FONT > face=Tahoma
> > size=2>-----Original Message-----<BR><B>From:</B> Ma. Irma G. >
Ambrocio
> > [mailto:[EMAIL PROTECTED]]<BR><B>Sent:</B> Wednesday, >
February
> > 20, 2002 2:49 PM<BR><B>To:</B>
> > [EMAIL PROTECTED]<BR><B>Subject:</B> get data from >
servlets to
> > applet and vice versa<BR><BR></FONT></DIV>
> > <DIV style="FONT: 10pt arial"></DIV>
> > <DIV><FONT face=Arial size=2>i have to generate a graph > using applet
but
> > the statistics i need is in a database so i have to use >
servlets.</FONT></DIV>
> > <DIV><FONT face=Arial size=2>but i have no idea how to pass > data
from
> > servlet to applet.</FONT></DIV>
> > <DIV><FONT face=Arial >
size=2>HELP!!!</FONT></DIV></BLOCKQUOTE></BODY></HTML>
> > <BR>
> > <BR>
> >
> > <P><B><FONT SIZE=2 FACE="Arial">DISCLAIMER: Information contained > and
transmitted by this E-MAIL is proprietary to MASCOT SYSTEMS LTD and > is
intended for use only by the individual or entity to which it is >
addressed, and may contain information that is privileged, confidential > or
exempt from disclosure under applicable law. If this is a forwarded >
message, the content of this E-MAIL may not have been sent with the >
authority of the Company. If you are not the intended recipient, an > agent
of the intended recipient or a person responsible for delivering > the
information to the named recipient, you are notified that any use, >
distribution, transmission, printing, copying or dissemination of this >
information in any way or in any manner is strictly prohibited. If you >
have received this communication in error, please delete this mail & >
notify us immediately at [EMAIL PROTECTED] Before opening >
attachments, please scan for viruses</FONT></B></P>
> > <BR>
> > <BR>
> >
> <BR><PRE>>
> >
___________________________________________________________________________
> > To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> > of the message "signoff SERVLET-INTEREST".
> >
> > Archives: http://archives.java.sun.com/archives/servlet-interest.html
> > Resources: http://java.sun.com/products/servlet/external-resources.html
> > LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
> >
> >
> </PRE>
>
>
___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html