dkim18
asked on
can I use multiple jstl string functions in one expression?
can I use multiple jstl string functions in one expression?
I want to capitalize the first letter?
is it possible?
<c:out value="${fn:substring.toUp pers(refer ence.citat ionType,0, 1)fn:subst ring(refer ence.citat ionType,1) }" /></td>
I want to capitalize the first letter?
is it possible?
<c:out value="${fn:substring.toUp
ASKER
I am trying to find out if I can do this in jstl.
Do you know how I can use the <fn:> string function in jsp page?
Do you know how I can use the <fn:> string function in jsp page?
I think this is more likely to work:
<c:out value="${fn:substring.toUp
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
<c:out value="${fn:toUpperCase(st ring2)}${f n:substrin g(referenc e.citation Type,1)}" /></td>
didn't work.
didn't work.
and what happened ?
And can you test if you have a simple thing like that working without first character:
<c:out value="${fn:substring(refe
Are you sure that in JSTL there is substring function with one int argument?
I don't see such option in the doc:
http://docs.oracle.com/javaee/5/jstl/1.1/docs/tlddocs/fn/substring.fn.html
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Still your problem was with not having the second argument in the substring function .
This should work:
at least this simple page which makes upper case first charcater of the string "this is first String" works nicely for me
Output:
This should work:
<c:set var="string2" value="${fn:substring(reference.citationType,0,1)}" />
<c:out value="${fn:toUpperCase(string2)}${fn:substring(reference.citationType,1,fn:length(reference.citationType))}" /></td>
at least this simple page which makes upper case first charcater of the string "this is first String" works nicely for me
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions"
prefix="fn" %>
<html>
<head>
<title>Using JSTL Functions</title>
</head>
<body>
<c:set var="string1" value="this is first String."/>
<c:set var="string3" value="${fn:substring(string1, 0, 1)}" />
<c:set var="string4" value="${fn:toUpperCase(string3)}" />
<c:set var="string5" value="${fn:substring(string1,1,fn:length(string1))}" />
<c:out value="${string4}${string5}"/>
</body>
</html>
Output:
This is first String.
I posted the JSTL solution.
for_yan, why did you take my solution and re-post it ?
for_yan, why did you take my solution and re-post it ?
rrz@871311,
I didn't even read what you posted - I was following my line through postings
37293088 and 37294739 where I explained the author what was the reason for his problem - and all that was long
before you even posted anything.
Then I typed in my example to confirm that my guess that the issue was with lacking argument in substring
was correct and tried to make this example similar to what author was doing, and I was busy doing it when you posted something.
I even didn't look at waht you posted - and frankly I don't see any similarity now.
ASKER
For some reason this worked
<c:set var="string2" value="${fn:substring(refe rence.cita tionType,0 ,1)}" />
<c:out value="${fn:toUpperCase(st ring2)}${f n:substrin g(referenc e.citation Type,1,fn: length(xxx xxx)}" /></td>
but not this one.
${fn:toUpperCase(fn:substr ing(name,0 ,1))}${fn: substring( name,1,fn: length(nam e))}
<c:set var="string2" value="${fn:substring(refe
<c:out value="${fn:toUpperCase(st
but not this one.
${fn:toUpperCase(fn:substr
ASKER
never mind.
This worked also.
Thanks much.
${fn:toUpperCase(fn:substr ing(name,0 ,1))}${fn: substring( name,1,fn: length(nam e))}
This worked also.
Thanks much.
${fn:toUpperCase(fn:substr
Rather use this function from
WordUtils.capitalize(str)
from apache coomons-lang
get jar form here:
http://apache.petsads.us//commons/lang/binaries/commons-lang3-3.1-bin.zip