You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Hohlen, John" <JH...@erac.com> on 2002/11/20 20:14:43 UTC

JSTL Question (EL vs. RT + Struts)

My team is starting a new project with Struts.  In our previous Struts
projects, our JSPs used mostly tags from the Struts tag libraries.  For our
new project, I want my team to start using the JSTL.  For that reason, the
"Struts-EL" subproject is very appealing because it will force our
developers to learn the JSTL  -- as functionality duplicated in the Struts
libraries (Bean & Logic) are removed when it is available in the JSTL.
Obviously, we'll still be using many of the Struts tags -- especially those
tied to the Struts framework (e.g. all tags in the Struts "html" library).
However, we're not sure whether to use the "Request Time" (RT) version or
the "Expression Language" (EL) version of the JSTL library.  And we have the
same question for the "Struts" subproject (Struts-EL or Struts-RT)?

Does anyone have any advice here?  Will JSTL compliant application servers
be required to implement a "EL" and "RT" version of the JSTL, or will they
only have to implement the "EL" version?

One other issue:  We want to reference constants declared in our Java files
in our JSP.  These are often the bean or error key constants.  This helps
guard against a String typo in the JSP as any mistyped constant name  will
get caught a JSP compile time -- where a string typo will not be detected
until JSP execution time.  Does anyone how to reference Java variables in
your JSP if you're using the JSTL-EL tags?  Is this even possible?  If not,
what are the alternatives?

Thanks,

JOHN



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


Re: JSTL Question (EL vs. RT + Struts)

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Wed, 20 Nov 2002, Hohlen, John wrote:

> Date: Wed, 20 Nov 2002 13:14:43 -0600
> From: "Hohlen, John" <JH...@erac.com>
> Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>
> To: "Struts-Help (E-mail)" <st...@jakarta.apache.org>
> Subject: JSTL Question (EL vs. RT + Struts)
>
> My team is starting a new project with Struts.  In our previous Struts
> projects, our JSPs used mostly tags from the Struts tag libraries.  For our
> new project, I want my team to start using the JSTL.  For that reason, the
> "Struts-EL" subproject is very appealing because it will force our
> developers to learn the JSTL  -- as functionality duplicated in the Struts
> libraries (Bean & Logic) are removed when it is available in the JSTL.
> Obviously, we'll still be using many of the Struts tags -- especially those
> tied to the Struts framework (e.g. all tags in the Struts "html" library).
> However, we're not sure whether to use the "Request Time" (RT) version or
> the "Expression Language" (EL) version of the JSTL library.  And we have the
> same question for the "Struts" subproject (Struts-EL or Struts-RT)?
>

The "EL" version is normally the one you want to use, because that is what
actually enables expression language support.

The "RT" version has exactly the same tags and attributes, but does not
recognize EL expressions.  It was created for the rare, but possible, case
that someone might have used a tag like this in a JSP page:

  <mytags:foo bar="${baz}"/>

and expected the "bar" property of the tag to actually receive "${baz}"
the way it would have prior to EL support.  (An EL-enabled version of the
tag would look up the "baz" attribute in page/request/session/application
scope and assign that value to bar.)

> Does anyone have any advice here?  Will JSTL compliant application servers
> be required to implement a "EL" and "RT" version of the JSTL, or will they
> only have to implement the "EL" version?
>
> One other issue:  We want to reference constants declared in our Java files
> in our JSP.  These are often the bean or error key constants.  This helps
> guard against a String typo in the JSP as any mistyped constant name  will
> get caught a JSP compile time -- where a string typo will not be detected
> until JSP execution time.  Does anyone how to reference Java variables in
> your JSP if you're using the JSTL-EL tags?  Is this even possible?  If not,
> what are the alternatives?
>

As was pointed out by others, the EL libraries don't recognize runtime
expressions so you can't use "<%= ... %>" to get these.  Your alternatives
would be:

* Go to the RT version (but give up EL expressions)

* Store the constants you need under some well known names,
  perhaps in application scope, so that you can use an
  EL expression to get them.

> Thanks,
>
> JOHN

Craig


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