As part of a project I'm working on, we're migrating from Velocity to JSP. I need to turn the set of existing Velocity templates into JSPs. We could spend hours discussing why this was decided (partly my fault), which one is better and the best way to dissuade management from this path, but that would be a waste of time as they are committed to having this done.
So, what I'm looking for is a set of patterns, best practices, what have you, to help me out. There's a lot of Velocity macros in the global library file which are used across a variety of templates. I'm thinking of converting each macro to a JSP scriptlet and translating the macro to Java. Then I would include that file with all the scriptlets into each JSP either via the include directive or jsp:include. I was also thinking of converting each call to a macro into a scriptlet. These macros have parameters that are beans defined in the Spring ModelAndView class.
Preliminary tests seems to indicate that this approach won't work. I seem to be getting JSP compile errors. But, I might be missing an error on my part.
I'm running this web app on OC4J version 10.1.3.4.0.
Here's a simple example of what I have to deal with. This is in the VM_global_library.vm file:
#macro( showObjectErrors $objectName)
#if ($request.errorSystem.hasErrors($objectName))
<table>
#foreach ($error in $request.errorSystem.getErrors($objectName))
<tr>
<td class="acError">$error</td>
</tr>
#end
</table>
#end
#end
And it's called in other files like so:
#showObjectErrors( "logonForm" )
Note that the "request" object is not an HttpServletRequest, but an application class. There are much more complex examples that are too much to show.