The Artima Developer Community
Sponsored Link

Java Answers Forum
pass variables from servlet to applet

1 reply on 1 page. Most recent reply: May 14, 2003 2:47 PM by Charles Bell

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
satwesh

Posts: 1
Nickname: satw
Registered: May, 2003

pass variables from servlet to applet Posted: May 13, 2003 4:47 AM
Reply to this message Reply
Advertisement
Hi i m satwesh here come across a prob in java servlet applet communication..prob i s that i have two files i m reading at server side and ploting graph in applet using fillrect().i have 2 plot in two diff graph-line(with different color).but i use the loop in applet where i have 2 put the total no of data in two files respectively.but my prob is how v can get that total data of each file for generalization rather putting it directly a no.

n=1873;
for(int i=1;i<=1042;i++){
g.setColor(Color.red);
g.fillRect(x+x_space,y_space+y_rang e-y,1,1);
}


for(int i=1043;i<=1873;i++){
g.setColor(Color.blue);
g.fillRect(x+x_space,y_space+y_ range-y,1,1);
}
so in place of n and within two loop i should put general variable so that any updation of data file(increase/decrease)of total data..it ll take automatically.

SECOND--- how to pass two variables suppose count1 and count2 (i.e total no of data in two files respectively from servlet 2 applet?


Charles Bell

Posts: 519
Nickname: charles
Registered: Feb, 2002

Re: pass variables from servlet to applet Posted: May 14, 2003 2:47 PM
Reply to this message Reply
The applet can open a url with the servlet, and read the response directly.

try{
URL url = new URL("http://127.0.0.1:8080/servlets/MyServlet?querystring");
InputStreamReader isr = new InputStreamReader(new BufferedInputStream(url.openStream()));
int c = 0;
while ((c = isr.read()) != -1){
responseString = responseString + String.valueOf((char)c);
}



You could use a jsp page and set the applet parameters dynamically and then have the applet code call the parameters.

Flat View: This topic has 1 reply on 1 page
Topic: MDA at work! OMG technology on share Previous Topic   Next Topic Topic: Applet Proxy, browser PAC file - need help

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use