You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Michael Ni <mi...@hotmail.com> on 2003/03/16 02:51:54 UTC
javabean constructors
can someone explain to me how contructors work with java beans in a jsp
page? heres my question, in the following bean foo1 which does not have a
constructor, if i usebean and then getA, i can get the value of 3
class foo1 {
int a = 3;
int b = 4;
//the rest of the get and set methods....
getA() {
return a;
}
}
but....
in foo2 if i usebean and then getA, the constructor is not setting the
values of a and b to the right value. a and b are left as null. How in a
jsp page do i active the constructor. I always assumed when you usebean it
activates the constructor.
class foo2 {
int a;
int b;
foo2() {
a = 3; b = 4;
}
//the rest of the get and set methods....
getA() {
return a;
}
}
mike
_________________________________________________________________
Add photos to your e-mail with MSN 8. Get 2 months FREE*.
http://join.msn.com/?page=features/featuredemail
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: javabean constructors
Posted by Henry Tang <he...@mail.utexas.edu>.
http://java.sun.com/products/jsp/tags/11/syntaxref1115.html
read above.
----- Original Message -----
From: "Michael Ni" <mi...@hotmail.com>
To: <to...@jakarta.apache.org>
Sent: Saturday, March 15, 2003 7:51 PM
Subject: javabean constructors
> can someone explain to me how contructors work with java beans in a jsp
> page? heres my question, in the following bean foo1 which does not have a
> constructor, if i usebean and then getA, i can get the value of 3
>
> class foo1 {
> int a = 3;
> int b = 4;
>
> //the rest of the get and set methods....
> getA() {
> return a;
> }
> }
>
> but....
> in foo2 if i usebean and then getA, the constructor is not setting the
> values of a and b to the right value. a and b are left as null. How in a
> jsp page do i active the constructor. I always assumed when you usebean
it
> activates the constructor.
>
> class foo2 {
> int a;
> int b;
>
> foo2() {
> a = 3; b = 4;
> }
>
> //the rest of the get and set methods....
> getA() {
> return a;
> }
> }
>
> mike
>
>
>
> _________________________________________________________________
> Add photos to your e-mail with MSN 8. Get 2 months FREE*.
> http://join.msn.com/?page=features/featuredemail
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org