Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

fn:trim question

 
billo bailey
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have some code which uses fn.tld but for some reason one line is not performing as I thought it would with fn:trim().



This is the line in question - <c:url value="${fn:trim(categories)}.jsp" />.
I want to trim "categories" for use a file name, but the actual link should keep whitespace in place. I put this - ${fn:toUpperCase("this")} - in to establish if it was because the tld could not be found but that is not the problem as it outputs "THIS".

Thanks for any ideas.

[ January 10, 2006: Message edited by: Bear Bibeault ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64835
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to trim "categories" for use a file name, but the actual link should keep whitespace in place.


So what's the problem? You don't describe what the source string is, what you are expecting, or what the actual output is.
 
billo bailey
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
woops, sorry bout that. categories could be "bike hire" in the database, a string, when trimmed the output I'd expect is bikehire. Basically all the categories will be two words max, I want foo bar -> foobar so I can do foobar.jsp. At the moment the output remains as foo bar.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64835
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you read the documentation for fn:trim you will see that it trims leading and trailing whitespace only.

Perhaps fn:replace will serve your purposes, or this might be a great opportunity to learn to write your own EL function.
 
billo bailey
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, fn:replace worked a treat, I put this in and it worked great


I'll leave the custom functions for a while until I get a bit more comfortable with servlets and JSP.

appreciate the help.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64835
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My pleasure.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic