Reputation: 383
I have a valid string of xml on a jsp(portlet version 1) project.
I am trying to use jstl tags to parse through it. Included tag libs:
<%@ page import="javax.portlet.*"%>
<%@ taglib prefix="x" uri="http://java.sun.com/jsp/jstl/xml"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
Currently I set the string:
String activexml = (String)renderRequest.getPortletSession().getAttribute("activexml");
Then I set my attribute for the jsp page:
pageContext.setAttribute("activexml", activexml);
This is all working, here comes the error. When I go to set the xml to be parsed. The C tag is good, no error comes back there, but the x receives the error:
<c:set var="active-xml" scope="session" value="${activexml}"/>
<x:parse xml="${active-xml}" var="active"/>
javax.servlet.jsp.JspTagException: Unrecognized object supplied as 'xml' attribute to parse
I have local copies of standard.jar and jstl.jar in my project. Any help would be most appreciated, I think it is either my syntax, or I am missing some project setup jars or something.
Thanks in advance.
Upvotes: 0
Views: 601
Reputation: 1109222
Your mistake is in the declared variable name.
<c:set var="active-xml" ... />
Like in Java, the hyphen is in EL interpreted as subtraction operator. The ${active-xml}
will basically give you the result of ${active}
minus ${xml}
.
Use an underscore instead.
<c:set var="active_xml" ... />
Or, just love Java code conventions a bit more and use camel case.
<c:set var="activeXml" ... />
Or, just use the original value right away without copying it via <c:set>
.
<x:parse xml="${activexml}" ... />
Upvotes: 1