wood burning stoves 2.0*
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 1016
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
 
Similar Threads
JSTL version causing exceptions?
toString method in vector.
casting double to int while using el
Taglibs not found problem
How to display data from an arraylist of more than one bean on jsp page using scripting or jsp tags?