JSON taglib not interpreting variables

193 views
Skip to first unread message

tkmilbaugh

unread,
May 28, 2009, 8:34:05 AM5/28/09
to json-taglib
No matter if I have page or request scope variables, the taglib will
not print out their values properly. I am using WebSphere 6.1.
If I have these lines:

<json:object>
<json:property name="context" value="${context0}"/>
</json:object>

My output is:

{"context":"${context0}"}

instead of what I expect (context0 holds "foo"):

{"context":"foo"}


James Wiltshire

unread,
May 28, 2009, 1:40:43 PM5/28/09
to json-taglib
Sounds like EL evaluation isn't being performed by container.
Checkout this similar thread...
http://groups.google.com/group/json-taglib/browse_thread/thread/9b6d169f664ed14e/9c18c0d607078cce?hl=en&lnk=gst&q=el#9c18c0d607078cce

Regards
James Wiltshire

tkmilbaugh

unread,
May 28, 2009, 1:56:16 PM5/28/09
to json-taglib
On May 28, 1:40 pm, James Wiltshire <jameswiltshir...@gmail.com>
wrote:
> Sounds like EL evaluation isn't being performed by container.
> Checkout this similar thread...http://groups.google.com/group/json-taglib/browse_thread/thread/9b6d1...
>
> Regards
> James Wiltshire
>

But EL evaluation is working for other taglibs, like <c:out value="$
{context0}" />, it works fine in the same page (tested before posting).

Jeremy Sears

unread,
May 28, 2009, 1:59:30 PM5/28/09
to json-...@googlegroups.com
What version of the servlet spec are you using?  When EL first came out, the tags were responsible for evaluating the EL expressions.  Subsequent implementations of the servlet spec (1.2 I believe) were required to have the container evaluate the EL expressions.
--
Jeremy Sears

tkmilbaugh

unread,
May 28, 2009, 2:59:05 PM5/28/09
to json-taglib
On May 28, 1:59 pm, Jeremy Sears <json.taglib.Jeremy.Se...@gmail.com>
wrote:
> What version of the servlet spec are you using?  When EL first came out, the
> tags were responsible for evaluating the EL expressions.  Subsequent
> implementations of the servlet spec (1.2 I believe) were required to have
> the container evaluate the EL expressions.
> --
> Jeremy Sears

I am specifying 2.4 in my web.xml:

<web-app id="WebApp_ID" version="2.4">

My server console log shows this:

SRVE0161I: IBM WebSphere Application Server - Web Container.
Copyright IBM Corp. 1998-2006
SRVE0162I: Servlet Specification Level: 2.4
SRVE0163I: Supported JSP Specification Level: 2.0

But my output still doesn't work:

{"context":"${context0}"} <-- printed with
<json:object><json:property name="context" value="${context0}"/></
json:object>
foo <-- printed with <c:out
value="${context0}" />

James Wiltshire

unread,
May 28, 2009, 3:46:40 PM5/28/09
to json-taglib
What happens when you just use ${context0} within your JSP? (i.e.
without using the <c:out> tag). If EL is enabled and working in the
page, then this should output the value 'foo'.
So...

<c:out value="${context0}/>
${context0}

should output

foo
foo

As Jeremy noted EL evaluation should be carried out by the container
for any web-app using servlet 2.4+ api. The container evaluates any EL
expressions prior to passing the values to any tags for processing -
that clearly isn't happening here.

Try using the full web-app tag declaration using the web-app2.4
schema...

<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

</web-app>

Regards
James Wiltshire

tkmilbaugh

unread,
May 28, 2009, 4:03:37 PM5/28/09
to json-taglib


On May 28, 3:46 pm, James Wiltshire <jameswiltshir...@gmail.com>
wrote:
> What happens when you just use ${context0} within your JSP? (i.e.
> without using the <c:out> tag). If EL is enabled and working in the
> page, then this should output the value 'foo'.
> So...
>
> <c:out value="${context0}/>
> ${context0}
>
> should output
>
> foo
> foo
>
> As Jeremy noted EL evaluation should be carried out by the container
> for any web-app using servlet 2.4+ api. The container evaluates any EL
> expressions prior to passing the values to any tags for processing -
> that clearly isn't happening here.
>
> Try using the full web-app tag declaration using the web-app2.4
> schema...
>
> <web-app version="2.4"
>       xmlns="http://java.sun.com/xml/ns/j2ee"
>       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>       xsi:schemaLocation="http://java.sun.com/xml/ns/j2eehttp://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
>
> </web-app>
>
> Regards
> James Wiltshire

My server fails to start when I include those attributes, throwing
dozens of exceptions.
Reply all
Reply to author
Forward
0 new messages