File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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 Android Security Essentials Live Lessons this week in the Android 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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: fmt jstl to re-format a phone number
 
Similar Threads
How to display data from an arraylist of more than one bean on jsp page using scripting or jsp tags?
casting double to int while using el
JSTL version causing exceptions?
toString method in vector.
Taglibs not found problem