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 Richard Berger <ri...@attbi.com> on 2002/09/19 20:00:57 UTC
Is it possible to reference scriptlet variables from a JSTL tag?
For example...
<jsp:useBean id="delegate" scope="page" class="golf.util.ResourceDelegate"/>
....
<% Collection coll = delegate.getReservationsForUserID(userid); %>
<c:forEach items="${coll}" var="teeTime">
I do not seem to be able to get this to work. Am I missing something, or do
I need to do this all in scriptlet world and forget about JSTL for this
problem?
Thanks much!
RB
PS - Many apologies if this is not the way to post to this mailing list - it
is my first try and there was no FAQ or user info for this list.
Re: Is it possible to reference scriptlet variables from a JSTL tag?
Posted by Hans Bergsten <ha...@gefionsoftware.com>.
Richard Berger wrote:
> For example...
> <jsp:useBean id="delegate" scope="page" class="golf.util.ResourceDelegate"/>
> ....
> <% Collection coll = delegate.getReservationsForUserID(userid); %>
> <c:forEach items="${coll}" var="teeTime">
>
> I do not seem to be able to get this to work. Am I missing something, or do
> I need to do this all in scriptlet world and forget about JSTL for this
> problem?
JSTL actions (or any other custom action) have no way to access
scripting variables, only "scoped variables". A scoped variable is the
same as an object stored as an attribute of any of the JSP scopes: page,
request, session and application. So you need to modify your code
like this:
<%
Collection coll = delegate.getReservationsForUserID(userid);
pageContext.setAttribute("col1", col1);
%>
<c:forEach items="${coll}" var="teeTime">
Hans
--
Hans Bergsten hans@gefionsoftware.com
Gefion Software http://www.gefionsoftware.com
JavaServer Pages http://TheJSPBook.com
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Is it possible to reference scriptlet variables from a JSTL tag?
Posted by Shawn Bayern <ba...@essentially.net>.
On Thu, 19 Sep 2002, Richard Berger wrote:
> For example...
> <jsp:useBean id="delegate" scope="page" class="golf.util.ResourceDelegate"/>
> ....
> <% Collection coll = delegate.getReservationsForUserID(userid); %>
> <c:forEach items="${coll}" var="teeTime">
>
> I do not seem to be able to get this to work. Am I missing something,
> or do I need to do this all in scriptlet world and forget about JSTL
> for this problem?
Tags, whether JSTL or not, cannot read scripting variables. Instead, you
need to make them scoped attributes, as with
<% pageContext.setAttribute("coll", coll); %>
--
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>