Format « JSTL « JSP-Servlet Q&A

1. Formatting a long timestamp into a Date with JSTL

I am pulling a long timestamp from a database, but want to present it as a Date using Tags only, no embedded java in the JSP.

I've created my own tag ...

2. JSTL/JSP EL (Expression Language) in a non JSP (standalone) context

Can anyone recommend a framework for templating/formatting messages in a standalone application along the lines of the JSP EL (Expression Language)? I would expect to be able to instantiate a an object ...

3. Format Date with fmt:formatDate JSP

I am trying to format a date with:

<fmt:formatDate value="${newsletter.createdOn}" pattern="MM/dd/yyyy"/>
newsletter is an object with a createdOn property which is java.util.Date. When I invoke the previous sentence I get: According to the ...

4. JSTL format tag?

I have a custom java.text.Format and would like to use it in my JSP. Is there a JSP/JSTL tag that can format an object using a custom java.text.Format? I'm looking for ...

5. Formatting file sizes in Java/JSTL

I was wondering if anyone knew of a good way to format files sizes in Java/JSP/JSTL pages. Is there a util class that with do this?
I've searched commons but ...

6. Ensuring configurable date format for each user across jsp's

JSTL provides the fmt:formatDate tag for formatting dates. The way to use it is: Now, in an application you do not want to specify the hardcoded format of "dd/MM/yyyy" in all your ...

7. fmt:formatNumber display negative currency in -$xxx.xx format in JSTL

I am using fmt:formatNumber to format currency in JSTL, it will display negative currency in ($100) format, how do I make it display negative currency in negative format instead of ($100)? thanks ...

8. How to format date in JSTL

I have a loop that goes through all the news items we have on our site. One of the fields is date ${newsitem.value['Date']}, given in millliseconds. I'd like to display this ...

9. How to format a number in Expression Language?

How can I make a formatted output for a number (e.g. long or BigDecimal) in EL? For example, I want to limit a number of decimal digits to 3 in


10. Formatting date with fmt:formatDate

I trying to format a date using fmt:formatDate.

 <c:forEach items="${list}" var="item">
       <!--some other columns-->

11. How to display a date by using c:out tag in some format

I am using JSTL. I want to display a date in JSP using <c:out ..> tag. I tried <c:out value = "<fmt:formatdate value = '${datevar}'"/>. But it displays as <fmt:formatdate value = '${datevar}' ...

12. JSTL and Format errors

Following the code.

<c:set var="birthdate"  value="${requestScope.evaluation.employee.birthDate}"></c:set>
<fmt:formatDate pattern="ddMMyyyy"  type="both" value="${birthdate}"/>
Error: Custom tag attribute value cannot be runtime expression. value: "[${birthdate}]"

13. How to format output in JSTL

I've got a span like this

and it returns something like John Brown how can i format it so it shows like BROWN, John in jstl?

14. JSTL formatDate always format the patten "MMM" to "Jan"

In the foreach loop, I set curMonth and curDisplayedMonth as follows:

<fmt:formatDate value="${curDate}" type="date" pattern="m" var="curMonth" />
<fmt:formatDate value="${curDate}" type="date" pattern="MMM" var="curDisplayedMonth" />
and used them in the dropdown list as
<option value="<c:out value="${curMonth}"/>" ...

15. Formatting GregorianCalendar in EL with JSTL/fmt

I'm having a small problem with a JSP page. I'm using Stripes as framework but this should not be that relevant. Basically I have a bean that returns via a getter a ...

16. How to display Java command-line error messages that are formatted as HTML?

I have an external library that is formatting notification messages in the form of HTML tables even though my program is displaying this information on the command line:

<table><tr><td>Some message</td></tr></table>
That's fine for ...

17. JSTL format tag

Trying to populate and formate a date value inside an INPUT text field. What am I doing wrong here?

<spring:bind path="salesData.weekEndDate">
 <input type="text" name="${status.expression}"
 value="${fmt:formateDate pattern='MM/mm/YYYY' status.value}"

18. How to set date pattern (date format) for an entire application?

In my web application I am currently using a custom DateUtil class to convert java.util.Date to String and vice versa. I am doing this only to convert to a default pattern ...

19. How do I format a number using jstl format tag?

I have a jsp page in which i need to display a number in this format. original number : 1234567890 Formatted number : 123-456-7890 How can we accomplish this using jstl fmt tag? To be ...

20. JSTL Format Number in million

I have a number like, 48371000000 i need to display it like 48371. Using JSTL, I tried like

<fmt:formatNumber var="salesFormat" type="currency" currencyCode="USD" value="48371000000"/>
Output: $48,371,000,000.00  
Do I need to use any pattern? Please Help, ...

21. fmt:formatNumber how to display deltas (+/-)

I want to use fmt:formatNumber to display the following:

  1. .8 => 80%
  2. -.8 => -80%
  3. 1721 => 1,721
  4. 1721 => +1,721
  5. -7876 => -7,876
UPDATE: The format works perfectly for percent and grouping, but it doesn't work ...

22. why JSTL number format value does not support runtime expressions?

I have this code:

<fmt:formatNumber type="number" 

23. JSTL question - format tag library

24. JSTL formatting issue

25. JSTL Formatting

Thanks for the posting tips =) I edited my post while you were posting...I realize now that I can't nest the tags, but what about EL? When using JSTL in 1.2, I can use ${myBean.ssn}, is this complicated to implement in my own tag? Thanks. [ August 23, 2005: Message edited by: Eric Martin ]

26. Formatting Currency Value in JSTL

27. fmt jstl to re-format a phone number

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 ...

28. Date pattern format problem JSTL tags

Hi, Sometimes i am facing the problem while displaying the data in my dashboard jsp page.It is showing the date as "2006-07-12" format.Sometimes it is showing as '07/12/2006'. I have used the following code to show the date in MM/dd/yyyy format. Here 'meetingDate' datatype is java.util.Date. But i am not able to see the date correctly at ...

29. Format column display - JSTL

31. JSTL number formatting

35. what is logic of JSTL fmt tag in formatting decimal numbers

hi , We have the below code in our jsp if the variable value is 6.650996 it prints 6.7 if the variable value is 6.652273 it prints 6.7 if the variable value is 6.65 it prints 6.6 we actually expect 6.65 also to be printed us 6.7,since the second decimal digit is ...

36. JSP code format

37. how to display data in a table format using jstl tag

hello friends, i am having a problem in displaying the data in a table format using jstl forEach tag. i am using springs and retrieving data from a controller using model and view and storing it in an ArrayList. now i want to display it to the user using a jsp page. Please help.

38. how to append data entered by user to XML file in proper format using JSP

hello i was appending my XML file to add more data entered by user in JSP page.But not getting XML file in proper format as XML rules.please help me to get XML file in proper format.I am using code: <%@page import="*,org.w3c.dom.*,javax.xml.parsers. *,javax.xml.transform.*, javax.xml.transform.dom.*,javax.xml.transform.stre am.*,javax.xml.*"%> untitled



39. JSTL date format for specific locale

40. Converting date to SQL format

Okay, so what I'm doing is getting a date as input from a form. That gives me 'day', 'month' and 'year' JSTL parameters. I want to then enter that date into a database using SQL. So I want to convert the three parameters into SQL date format. I've tried googling this and got a few results but none of them worked. ...

41. JSTL Format Number