Before I write a custom tag to do this, I want to be sure I didn’t miss something in EL or JSTL.
There’s an int returned by a bean property that is stored in the request scope. I need to output it as hex. But after searching, it seems there is no way in JSP to output an int that is returned from a bean by EL thusly…
${someBean.someInt}
…as a hexadecimal value, in the way that…
<%= String.format("0x%X", someBean.getSomeInt()) %>
…would.
Am I correct? If not, how is it done? (Our departmental coding standards disallow Java directly included in JSP using the <% %> syntax. We have to write tags if we can’t find something already available.)
You can’t do this in EL or using JSTL’s formatting tags. Writing a custom tag or EL function is the best option.
If it’s just one
intyou have to format you could add a String getter to your bean to do the formattingand then you could use that getter in EL