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 Marco Mistroni <mm...@gmail.com> on 2005/06/16 21:06:27 UTC

Still Struggling with JSTL and c:forEach :-(

Hello all,
  after suggestion from Sammy, i managed to get a step further in my
application where i am trying to replace Struts tags with JSTL... but
today i got another exception.. :-(

Situation is that i have in servletContext an attribute called
EXPENSE_TYPES, of type java.util.List.
THe List is a list of ExpenseType objects, which have two properties, 
id and description, which i want to display in my jsp.
so i wrote following code:

<c:forEach var="expense" items="${applicationScope.EXPENSE_TYPES}>" >	
      <c:out value="${expense.description}"/><br/>
</c:forEach>

but when i run my jsp, i got following exception:

18:59:59,812 ERROR [Engine] StandardWrapperValve[StrutsActionServlet]: Servlet.s
ervice() for servlet StrutsActionServlet threw exception
javax.servlet.jsp.JspException: ServletException in '/layout/classicLayout.jsp':
 ServletException in '/insertBody.jsp': An error occurred while evaluating custo
m action attribute "value" with value "${expense.description}": Unable to find a
 value for "description" in object of class "java.lang.String" using operator ".
" (null)

to me it looks like for some reasons it is trying to get a description
property from 'item', which is a String.. but wasn't it supposed to be
my ExpenseType object? how come now it became a String?

any help will be appreciated....

i am using JBoss 3.2.5 which is compatible with servlets 2.3 version

thanx in advance and regards
   marco

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: Still Struggling with JSTL and c:forEach :-(

Posted by Marco Mistroni <mm...@gmail.com>.
hello all,
  thanx a lot Rahul, it was a typo.....

regards
 marco

On 6/17/05, Marco Mistroni <mm...@gmail.com> wrote:
> Hello,
>   sorry....well i have code @home so i'll have to get back later
> today or tomorrow
> i have stored in ServletContext a  List of ExpenseType objects under
> the name 'EXPENSE_TYPES'
> 
> I can retrieve it successfully (i did a dummy print whithin c:forEAch
> and it printed correctly 11 lines (which is the number of elements in
> the list).
> 
> Wendy, if i write
> <c:out value="${expense}"/>  the String representation of my object
> gets printed, which is
> <id=1  description=foobar/>
> 
> before i was using a Struts tag for retrieving EXPENSE_TYPES attribute
> and it was working fine...
> 
> i'll try what Wendy suggested
> 
> <c:out value="${applicationScope.EXPENSE_TYPES}" />
> 
> and get back to you all..
> 
> thanx and regards for your help
> 
> marco
> 
> On 6/16/05, Wendy Smoak <ja...@wendysmoak.com> wrote:
> > From: "Marco Mistroni" <mm...@gmail.com>
> > > <c:forEach var="expense" items="${applicationScope.EXPENSE_TYPES}>" >
> > >       <c:out value="${expense.description}"/><br/>
> > > </c:forEach>
> > >
> > > ServletException in '/insertBody.jsp': An error occurred while evaluating
> > > custom action attribute "value" with value "${expense.description}":
> > > Unable to find a value for "description" in object of
> > > class "java.lang.String" using operator "." (null)
> >
> > What does <c:out value="${applicationScope.EXPENSE_TYPES}" /> print?
> >
> > Try it with just <c:out value="${expense}"/> in the middle.  What do you
> > get?
> >
> > For some reason, 'expense' is a String.  Maybe your List doesn't contain
> > what you think it does.
> >
> > --
> > Wendy Smoak
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
> >
> >
>

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: Still Struggling with JSTL and c:forEach :-(

Posted by Marco Mistroni <mm...@gmail.com>.
Hello,
   sorry....well i have code @home so i'll have to get back later
today or tomorrow
i have stored in ServletContext a  List of ExpenseType objects under
the name 'EXPENSE_TYPES'

I can retrieve it successfully (i did a dummy print whithin c:forEAch
and it printed correctly 11 lines (which is the number of elements in
the list).

Wendy, if i write 
<c:out value="${expense}"/>  the String representation of my object
gets printed, which is
<id=1  description=foobar/>

before i was using a Struts tag for retrieving EXPENSE_TYPES attribute
and it was working fine...

i'll try what Wendy suggested

<c:out value="${applicationScope.EXPENSE_TYPES}" />

and get back to you all.. 

thanx and regards for your help

marco

On 6/16/05, Wendy Smoak <ja...@wendysmoak.com> wrote:
> From: "Marco Mistroni" <mm...@gmail.com>
> > <c:forEach var="expense" items="${applicationScope.EXPENSE_TYPES}>" >
> >       <c:out value="${expense.description}"/><br/>
> > </c:forEach>
> >
> > ServletException in '/insertBody.jsp': An error occurred while evaluating
> > custom action attribute "value" with value "${expense.description}":
> > Unable to find a value for "description" in object of
> > class "java.lang.String" using operator "." (null)
> 
> What does <c:out value="${applicationScope.EXPENSE_TYPES}" /> print?
> 
> Try it with just <c:out value="${expense}"/> in the middle.  What do you
> get?
> 
> For some reason, 'expense' is a String.  Maybe your List doesn't contain
> what you think it does.
> 
> --
> Wendy Smoak
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: Still Struggling with JSTL and c:forEach :-(

Posted by Wendy Smoak <ja...@wendysmoak.com>.
From: "Marco Mistroni" <mm...@gmail.com>
> <c:forEach var="expense" items="${applicationScope.EXPENSE_TYPES}>" >
>       <c:out value="${expense.description}"/><br/>
> </c:forEach>
>
> ServletException in '/insertBody.jsp': An error occurred while evaluating
> custom action attribute "value" with value "${expense.description}":
> Unable to find a value for "description" in object of
> class "java.lang.String" using operator "." (null)

What does <c:out value="${applicationScope.EXPENSE_TYPES}" /> print?

Try it with just <c:out value="${expense}"/> in the middle.  What do you
get?

For some reason, 'expense' is a String.  Maybe your List doesn't contain
what you think it does.

-- 
Wendy Smoak




---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: Still Struggling with JSTL and c:forEach :-(

Posted by Rahul P Akolkar <ak...@us.ibm.com>.
Marco Mistroni <mm...@gmail.com> wrote on 06/16/2005 03:06:27 PM:
<snip/>
> <c:forEach var="expense" items="${applicationScope.EXPENSE_TYPES}>" > 

Marco - Are you sending us typos again? ;-) If you copied and pasted 
correctly, then it seems your items attribute value has an extra '>' 
character.

-Rahul