I guess that you are just trying to get familiar with JSP's. In general, having methods in JSP's turns into a maintenance nightmare. You should do all your processing in normal Java classes, and use JSP's only to display the data.
The <%= %> tags only work to print out a string that is returned by the code betweent them.
I believe that was the intent of the poster.
And, it doesn't have to be a string; the expression within the delimiters can return any class or primitive. In the case that a class is returned, the toString() method is called on the class to determine the value to emit.