hi all,
i am trying to pass a vector from a
servlet to an
applet,following is the code for both of them,the problem is that when i run the applet the vector which supposedly should receive the value from the servlet's vector,shows a value of zero,is the servlet isnt passing any vector to the applet afterall..
SERVLET PART:
public void senddata(HttpServletResponse response) throws IOException {
ObjectOutputStream outputToApplet = null;
try {
outputToApplet = new ObjectOutputStream(response.getOutputStream());
outputToApplet.writeObject(vec);
outputToApplet.flush();
outputToApplet.close();
}
catch(Exception e) {
System.out.println("MyServlet: senddata() "+e.toString());
}
}
HERE "vec" is the vector which i am trying to pass to the applet,vec has been given some value in the while loop of the resultset.
APPLET PART:
public Vector getdatafromServlet() {
ObjectInputStream inputFromServlet = null;
try {
String servletLocation ="http://localhost:8080/servlet/myserv";
URL servletURL = new URL(servletLocation);
URLConnection servletConnection = servletURL.openConnection();
servletConnection.setDoInput(true);
servletConnection.setDoOutput(true);
servletConnection.setUseCaches(false);
servletConnection.setDefaultUseCaches(false);
servletConnection.setRequestProperty("Content-Type","application/octet-stream");
inputFromServlet = new ObjectInputStream(servletConnection.getInputStream());
myvec = (Vector)inputFromServlet.readObject();
inputFromServlet.close();
}
catch(ClassNotFoundException e) {}
catch(Exception e){}
finally {
return myvec;
}
}
//this is the function in which i call getdatafromServlet()
void draw(Graphics g){
g.setColor(Color.black);
g.fillRect(0,v3,v2,1000);
g.setColor(Color.green);
g.drawRect(500,400,100,100);
myvec1 = getdatafromServlet();
System.out.println(myvec1.size());//shows a value of zero
Enumeration venum = myvec1.elements();
while(venum.hasMoreElements())
{System.out.println(myvec1);}
g.setColor(Color.blue);
g.setFont(new Font("TimesRoman",Font.BOLD,25));
g.drawString(msg,v4,v5);
}
please please help me..its very urgent
thanks a million
karan