Hi all, this is my first post and i don't speak english very well...excuse me for that. And i am a novice of JSP / JAVA :-(
I have created in my Java application a Factory Method ( example with 2 different class):
interface Interf {
public void myfunction(); }
class Class1 / Class2 implements Interf {
public void myfunction() { ...... }
}
abstract class FactoryObj {
abstract Interf createobj();
}
class FactoryClass1 extends FactoryObj {
Interf createobj() { return (Interf) new Class1(); }
}
class FactoryClass2 extends FactoryObj {
Interf createobj() { return (Interf} new Class2(); }
}
And in my java application i can use this linecode for execute the myfunction of CLass1.....
FactoryObj a = new FactoryClass1();
Interf o = a.createobj();
o.myfunction();
Now i must add all this factory method in my EXAMPLE.JSP. After that i import the page Project.Factory when i have all the code that i have posted , and i make
<% FactoryObj a = new FacotryCLass1(); %> i can see the error :
FactoryObj cannot be resolved to a type ( maybe because is a static object...) and cannot execute le myfunction() :-( :-( :-(
Anyone can help me??? Maybe i must use another implementation of Factory without an abstract class....
Thank, Andrea
I have created in my Java application a Factory Method ( example with 2 different class):
interface Interf {
public void myfunction(); }
class Class1 / Class2 implements Interf {
public void myfunction() { ...... }
}
abstract class FactoryObj {
abstract Interf createobj();
}
class FactoryClass1 extends FactoryObj {
Interf createobj() { return (Interf) new Class1(); }
}
class FactoryClass2 extends FactoryObj {
Interf createobj() { return (Interf} new Class2(); }
}
And in my java application i can use this linecode for execute the myfunction of CLass1.....
FactoryObj a = new FactoryClass1();
Interf o = a.createobj();
o.myfunction();
Now i must add all this factory method in my EXAMPLE.JSP. After that i import the page Project.Factory when i have all the code that i have posted , and i make
<% FactoryObj a = new FacotryCLass1(); %> i can see the error :
FactoryObj cannot be resolved to a type ( maybe because is a static object...) and cannot execute le myfunction() :-( :-( :-(
Anyone can help me??? Maybe i must use another implementation of Factory without an abstract class....
Thank, Andrea