Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

jstl function to get right customer number

Status
Not open for further replies.

GoSooJJ

Programmer
Feb 24, 2001
76
US
I have a customer number as 000-000000-000000. I'd like to have if statement that check for length is 17 and first 3 digits are number and 5-11 is number and 13-17 is number. I'm very new to jsp 2.0 and willing to convert my coldfusion to jsp page by using jstl tag.
Can someone help me on this?

thank you.
 
perfect task for Regular Expressions

adjust to a pattern of something as
[\d]{3}(-)[\d]{6}(-)[\d]{6}


_____________________________________________________________________
onpnt2.gif

Hakuna matata!!
 
your very welcome and hope it helped

_____________________________________________________________________
onpnt2.gif

Hakuna matata!!
 
ok, now i'm facing how to use this in jstl page. here is my code.

<c:choose>
<c:when test=&quot;${not empty param.cid}&quot;>
<c:set var=&quot;cidFormat&quot; value=&quot;[\d]{3}(-)[\d]{6}(-)[\d]{6}}&quot; />
<c:choose>
<c:when test=&quot;${param.cid.match(cidFormat)}&quot;>
good cid
</c:when>
<c:eek:therwise>
bad cid
<%--<c:redirect url=&quot;error.jsp&quot; />--%>
</c:eek:therwise>
</c:choose>
</c:when>
<c:eek:therwise>
<%--<c:redirect url=&quot;error.jsp&quot; />--%>
</c:eek:therwise>
</c:choose>

of course, i'm getting an error that &quot;The function match must be used with a prefix when a default namespace is not specified&quot;. I do not know how to plug in. It's really hard to find any examples from web since jstl is pretty new...
 
there's a extra } in there
=&quot;[\d]{3}(-)[\d]{6}(-)[\d]{6}}&quot; <--

to
=&quot;[\d]{3}(-)[\d]{6}(-)[\d]{6}&quot;

I'll take a look at the complete in a sec if someone else does not

_____________________________________________________________________
onpnt2.gif

Hakuna matata!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top