tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "John Townsend" <john.towns...@listenpoint.com>
Subject xtags:ForEach question (involving parameters)
Date Thu, 12 Jul 2001 22:52:43 GMT
I am having a problem with forEach in the xtags library. I am trying to
use XPath and xtags to select all of the person entries from my
directory that contain a substring (For example, all of the people who
have 'John' in their name). 

I have an XML file that looks basically like this:

<directory>
	<person>
		<name>John Townsend</name>
		...more data...
	</person>
</directory>

Here's a piece of my JSP page: 

	<xtags:forEach select = "//person[child::name[contains(text(),
'$param')]]">
      <TR>
        <TD align=right><xtags:valueOf
select="employee-number"/>&nbsp;&nbsp;</TD>
          <TD><xtags:valueOf select="name"/></TD>
          <TD><xtags:valueOf select="title"/></TD>
          <TD><A 
              href="mailto:<xtags:valueOf
select="email"/>"><xtags:valueOf select="email"/></A></TD>
          <TD><NOBR><xtags:valueOf select="phone"/></NOBR></TD>
          <TD><NOBR><xtags:valueOf select="cell"/></NOBR></TD>
          <TD><NOBR><xtags:valueOf select="home"/></NOBR></TD>
          <TD><xtags:valueOf select="messenger"/></TD></TR>
     </xtags:forEach>

If my select in the forEach looks like this:

Select = "//person[child::name[contains(text(), 'John')]]"

Then it works. But, I would like to pass in the 'John' parameter from
the URL. The URL would look something like this:

http://localhost:8080/myapp/mypage.jsp?param=John

Can I do this? I thought if I put $param in my select statement it would
work, but it didn't seem to work.

Any ideas? Forgive my ignorance of XPath, I am just starting to use the
xtags library and XPath.

-- towns



Mime
View raw message