Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

fmt jstl to re-format a phone number

 
Troy Archbold
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would like to use the fmt jstl taglib in a JSP page to format and display a phone number. I would rather not format it in an Java action class or another class. I have received the advice to use the fmt jstl taglib but I do not see how a phone number can be formatted with any of its tags. Maybe it's not an option. Has anyone done this before? Thanks.

The phone number originally looks like: 5555555555
and I want to reformat it to 555-555-5555.
 
Stefan Evans
Bartender
Posts: 1690
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not the JSTL <fmt> tags won't help you here.
They can only handle number/date formatting.
They are written as a tag interface to the java.text packages for NumberFormat and DateFormat. Neither of those classes will help you with formatting a telephone number.
I would probably go with
- a custom tag
- a static method to do the formatting, and call it via an EL function (JSP2.0)

Either way, some java code will have to be written.
 
Troy Archbold
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'll do it in Java then. Thanks for the info.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic