You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-user@tomcat.apache.org by Felipe Schnack <fe...@ritterdosreis.br> on 2002/09/21 19:52:18 UTC

declaring variables

  I really would like to declare scriptlet variables valid only inside the
body of a tag. But as far as I can understand the "ExtraInfo" tags, I can't do
anything much beyond create variables with constant names or based on tag's
attributes. 
  There is a way I can declare totally dinamic variable names from tags? Like
get data from the tag and use it to declare variables?

Felipe Schnack
Analista de Sistemas
felipes@ritterdosreis.br
Cel.: (51)91287530
Linux Counter #281893

Faculdade Ritter dos Reis
www.ritterdosreis.br
felipes@ritterdosreis.br
Fone/Fax.: (51)32303328


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: declaring variables

Posted by Shawn Bayern <ba...@essentially.net>.
On Sat, 21 Sep 2002, Felipe Schnack wrote:

> I really would like to declare scriptlet variables valid only inside
> the body of a tag. 

This is possible but separate from the other things you ask for you in
your method.  The spec supports NESTED visibility to make a scripting
variable available only within the body of your tag.

> But as far as I can understand the "ExtraInfo" tags, I can't do
> anything much beyond create variables with constant names or based on
> tag's attributes.
>   There is a way I can declare totally dinamic variable names from
> tags? Like get data from the tag and use it to declare variables?

No, this is a limitation based on the way JSP works.  For a scripting
variable to be declared, its name must be known at translation time so
that the proper declaration statement can be added to the servlet to which
your JSP page compiles.

Note that you can simply insert variables with arbitrary names, chosen at
request time, into one of the several "scopes" and then refer to it either
with <%= pageContext.findAttribute() %> or with JSTL's expression
language.

-- 
Shawn Bayern
"JSTL in Action"   http://www.jstlbook.com


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>