my dog learned polymorphism*
The moose likes JSP and the fly likes fn:trim question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "fn:trim question" Watch "fn:trim question" New topic
Author

fn:trim question

billo bailey
Ranch Hand

Joined: Dec 02, 2002
Posts: 50
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 ]

only users lose drugs
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60057
    
  65

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
billo bailey
Ranch Hand

Joined: Dec 02, 2002
Posts: 50
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

Joined: Jan 10, 2002
Posts: 60057
    
  65

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

Joined: Dec 02, 2002
Posts: 50
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

Joined: Jan 10, 2002
Posts: 60057
    
  65

My pleasure.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: fn:trim question
 
Similar Threads
What is the point of c:out ?
Using checkbox on Spring 2.5 MVC ?
Not able to print the items in the List
Form Being Rendered Outside of the Page
JSTL not working