You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Egidijus Drobavicius <eg...@vb.lt> on 2001/05/31 10:42:47 UTC
jsp:usebean
Hi,
I've got one question:
I'd like to keep the constant string values in the single place to avoid the
mess. So I have class Constants.
let's say Constants have atrribute ATTR_MY_HANDLER="myHandler"
I use then code like this session.getAttribute(Constants.ATTR_MY_HANDLER).
This is OK
In jsp side i'd like to store this bean to session using jsp:usebean
directive.
But as i see the parser gets confused at this point if i write smth like
this
<jsp:useBean id=Constants.ATTR_MY_HANDLER scope="session" class="MyHandler"
/>
It insists that id value is of type String and is placed between "".
Is it possible to work around in nice way this situation or do I have to
place this attribute to the session manualy? I do hate using same attribute
in several places as it definetly leads to mistakes (i.e. I will not use
<jsp:useBean id="myHandler" scope="session" class="MyHandler" />
Regards,
Egidijus Drobavicius
AB Vilniaus Bankas
http://www.vb.lt
tel. + 370 2 682706
Egidijus Drobavicius
AB Vilniaus Bankas
http://www.vb.lt
tel. + 370 2 682706
Re: jsp:usebean
Posted by Egidijus Drobavicius <eg...@vb.lt>.
Nope, but this is not actually var name. This is key for the hashtable.
And if i'd like to use SAME bean in two different places, i have to use SAME
key to retrieve the bean, i.e.
<jsp:useBean id="myHandler" scope="session" class="MyHandler" />
<jsp:useBean id="myHandler1" scope="session" class="MyHandler" />
will create 2 objects and place them to session hash;
As long as the project is maintained by few people, i'd like to have these
var names defined to avoid mistyping and similar problems (you must admin,
that it is much easier to get compile time error saying that ATTR_MY_HANDLEW
is not defined than debug the code and find out that some person wrote
getAttribute ("myHandlew"))
Maybe i'm wrong, but this is my attitude :)
Regards,
Egidijus
----- Original Message -----
From: "Edwin Martin" <ed...@bitstorm.nl>
To: <to...@jakarta.apache.org>
Sent: Thursday, May 31, 2001 11:21 AM
Subject: Re: jsp:usebean
> Egidijus,
>
> > I do hate using same attribute
> >in several places as it definetly leads to mistakes (i.e. I will not use
> ><jsp:useBean id="myHandler" scope="session" class="MyHandler" />
>
> You have a strange way of thinking, friend,
>
> You have to look at myHandler as a variable name.
>
> Do you store the name of a variable in a constant to clean up
> you code?
>
> Bye,
> Edwin Martin.
>
>
Re: jsp:usebean
Posted by Edwin Martin <ed...@bitstorm.nl>.
Egidijus,
> I do hate using same attribute
>in several places as it definetly leads to mistakes (i.e. I will not use
><jsp:useBean id="myHandler" scope="session" class="MyHandler" />
You have a strange way of thinking, friend,
You have to look at myHandler as a variable name.
Do you store the name of a variable in a constant to clean up
you code?
Bye,
Edwin Martin.