aspose file tools*
The moose likes JSP and the fly likes fmt jstl to re-format a phone number Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "fmt jstl to re-format a phone number" Watch "fmt jstl to re-format a phone number" New topic
Author

fmt jstl to re-format a phone number

Troy Archbold
Greenhorn

Joined: May 17, 2005
Posts: 15
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

Joined: Jul 06, 2005
Posts: 1027
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

Joined: May 17, 2005
Posts: 15
I'll do it in Java then. Thanks for the info.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: fmt jstl to re-format a phone number