On my JSP page I import a java class as
<%@page import="org.model.MyConstants"%>
In the MyConstants class I have a public function
public static String getBookTypeName(int bookTypeId){
//lots of if's based on id
String bookName = 'Fantasy';
return bookName;
}
Now from my JSP page I am trying to call this function passing in a request bean value as the parameter.
Essentially one property of my bean is an integer which I used to display, now I want to display the String that goes along with it but want to do so in a way where I dont need to modify the bean and can just use my MyConstants method to get the string.
I have been outputting my bean value before using
<bean:write name="BookNotifyForm" property="bookTypeId" />
I have been able to use scriplets in the past but have never had to pass a bean value into it.
<c:out value="<%=MyConstants.SOME_STRING_OUTPUT %>" />
I think I have the idea down but the syntax is what is killing me. I believe I should be able to use c:set to store the bean variable, and then use c:out calling the method passing in the variable I stored. Something along the lines of....
<c:set var="bookTypeId" value="${BookNotifyForm.bookTypeId}" />
//help with syntax, trying
<c:out value="<%=MyConstants.getBookTypeName(bookTypeId) %>" />
<c:out value="<%=MyConstants.getBookTypeName(${bookTypeId}) %>" />
It must be possible to do something like this !?