We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › applet export problems with BufferedReader
Page Index Toggle Pages: 1
applet export problems with BufferedReader (Read 549 times)
applet export problems with BufferedReader
Sep 10th, 2006, 12:37am
 
hi,

I have problems when export my skecth with BufferedReader only in when export applet, not in application and when compile inside processing aplicattion.

Code:

BufferedReader reader;
String csvString,name, joker;
float dayChange;

void setup(){
feed();
coloring();
}
void feed(){
try {
println("getting started...");
reader = reader("http://es.old.finance.yahoo.com/d/quotes.csv?s=ELE.MC&f=sl1d1t1c1ohgv&e=.csv");
println("got reader...");
String line = null;
// read lines one at a time
if((line = reader.readLine()) != null) {
println(line);
csvString = line;
}
println("done reading.");
StringTokenizer tokenizer = new StringTokenizer(csvString, ",");

name = tokenizer.nextToken();// println("tradeDate : "+tradeDate );
joker = tokenizer.nextToken();
joker = tokenizer.nextToken();
joker = tokenizer.nextToken();

try{
dayChange = Float.parseFloat(tokenizer.nextToken());
println("day Change ->"+dayChange);
}
catch(NumberFormatException e) {
}

}
catch (IOException e) {
e.printStackTrace();
}
}
void coloring(){
int r,g,b;
if (dayChange!=0.0){
if (dayChange < 0.0){r= (int)Math.abs(255.0*dayChange);}else{r=0;};
if (dayChange > 0.0){g= (int)(255.0*dayChange);}else{g=0;};
b=0;
background(r,g,b);
}else{
background(255,255,255);
}
}



This sketch exported is now in http://www.derivart.info/visualizaciones/index_background/

thanks,

Mar
PD: My Java runtime is the version: 1.5.0_83-b03.And I try with Mozilla 1.5.0.6 and IE 6.0.29 .
Re: applet export problems with BufferedReader
Reply #1 - Sep 10th, 2006, 2:56am
 
it's a security issue, see the faq:
http://processing.org/faq/bugs.html#applet
Re: applet export problems with BufferedReader
Reply #2 - Sep 10th, 2006, 10:46am
 
Thanks fry,

I read faq, I think the security problem is:
Applets may only connect to servers other than the one from which they came. If you need to redirect things from another server, you can write a short script that will do it, understanding the possible security consequences for your own machine.

But now I try the sketch read a php file which read data from other server. And It following with out read nothing. I'm wondering if I understand well the java security issue.


PHP script(called "extractor.php")
Code:

<?php

$mifichero = "http://es.old.finance.yahoo.com/d/quotes.csv?s=ELE.MC&f=sl1d1t1c1ohgv&e=.csv";

if ($mi_array=file($mifichero)) {
while (list ($linea, $contenido) = each ($mi_array)) {
echo $contenido;
}
}

?>


Sketch in processing:
Code:

BufferedReader reader;
String csvString,name, joker;
float dayChange;

void setup(){
feed();
coloring();
}
void feed(){
try {
println("getting started...");
reader = reader("extractor.php");
println("got reader...");
String line = null;
// read lines one at a time
if((line = reader.readLine()) != null) {
println(line);
csvString = line;
}
println("done reading.");
StringTokenizer tokenizer = new StringTokenizer(csvString, ",");

name = tokenizer.nextToken();// println("tradeDate : "+tradeDate );
joker = tokenizer.nextToken();
joker = tokenizer.nextToken();
joker = tokenizer.nextToken();

try{
dayChange = Float.parseFloat(tokenizer.nextToken());
println("day Change ->"+dayChange);
}
catch(NumberFormatException e) {
}

}
catch (IOException e) {
e.printStackTrace();
}
}
void coloring(){
int r,g,b;
if (dayChange!=0.0){
if (dayChange < 0.0){r= (int)Math.abs(255.0*dayChange);}else{r=0;};
if (dayChange > 0.0){g= (int)(255.0*dayChange);}else{g=0;};
b=0;
background(r,g,b);
}else{
background(255,255,255);
}
}


It's in the same place:http://www.derivart.info/visualizaciones/index_background/

Mar
Re: applet export problems with BufferedReader
Reply #3 - Sep 11th, 2006, 2:58pm
 
ah bummer, now you've stumbled upon a bug that has surfaced in recent releases. or at least, depends on how you look at it.

there are two solutions, in the meantime:
1. use the full url (i.e. http://blahblah..)
2. put extractor.php into a subfolder called "data"

either of these will get things working. the "bug" is that i disabled checking in the root directory when online--older releases would have checked data/extractor.php *and* extractor.php. i should prolly just re-enable that, so i'll file a bug for it here:
http://dev.processing.org/bugs/show_bug.cgi?id=389
Re: applet export problems with BufferedReader
Reply #4 - Sep 11th, 2006, 4:13pm
 
Ok, the solution number 1 solve the problem.
http://www.derivart.info/visualizaciones/index_background2/
And also I try second one but It's not working.
http://www.derivart.info/visualizaciones/index_background3/

Thanks for you help,

Mar
Page Index Toggle Pages: 1