Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSTL tag with bean:write tag

 
Yashwant Palkar
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to use <fmt:formatNumber> with <bean:write> tag in JSP. Please find the following code snippet



For this above error I am getting this error.

"org.apache.jasper.JasperException: XYZ.jsp(49,64) equal symbol expected"


I am not sure it is right or wrong. Can anybody suggest me proper syntax for this?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65111
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't use one custom tag within another custom tag. Rather than the proprietary <bean:write> tag use the EL.
 
Stefan Evans
Bartender
Posts: 1777
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
While you can't use one custom tag as an attribute to another custom tag, you can nest them, and the <fmt:formatNumber> tag supports that use case explicitly:



Having said that though, the equivalent of the bean:write tag should just be ${name.property} ie: ${sb.accountNumber}
So in this case I would go with the EL expression and the value attribute.

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65111
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I also think it's a good practice to use the standard means over the proprietary means even when using a framework.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic