temp temp wrote:

 I want    index of substring from a string . I would
like to acheive this using jsp tags. I found jakarta taglib countMatches tag which would print
 no of times  substring is present in the
string.Rather than printing  I want to capture  the
output from this jsp tag into a variable .This tag
also provides  this ability  by declaring var
attribute  which will capture the result of this tag.
My problem is I am unable to declare a var attribute
in this jsp tag or I  doing somethig wrong with the
syntax of this tag.Can somebody guide me the proper
syntax for using this tag.
<str:countMatches substring="world">Hello world
programs are rife in this world due to their worldy
view of how to program a world of
code</str:countMatches>
thanks & regards

countMatches isn't a Struts tag, but a quick google search for it's documentation [1] would suggest the following should be what you want:

  <str:countMatches var="count" substring="world">...</str:countMatches>

I don't see how that's going to get you what you wanted, though, since it would set 'count' to the number of times 'world' apears in the body text, not to the index of the first occurrence.

To do that, look at the indexOf function in the JSTL taglibs [2]. If you still need help getting countMatches to work you should ask on the taglibs-user list [3].

L.

[1] http://jakarta.apache.org/taglibs/doc/string-doc/string-1.1.0/
[2] http://java.sun.com/products/jsp/jstl/1.1/docs/tlddocs/fn/indexOf.fn.html
[3] http://jakarta.apache.org/taglibs/index.html#MailingLists

--
Laurie, Open Source advocate, Java geek and novice blogger:
http://www.holoweb.net/laurie


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to