When migrating a large project, you may want to convert JSP tags to jte incrementally. The converter uses a "bridging tag" to allow jte templates to be embedded within existing JSP files.
If the converter encounters an un-converted tag (e.g., <my:example/>), it will replace it in the JSP with the bridging tag syntax:
<my:jte jte="path/to/template.jte" param1="value" />.
To make this work, you must:
- Implement a custom JSP Tag class (extending
BodyTagSupport and DynamicAttributes) that uses a TemplateEngine to render the specified jte template. - Handle parameter conversion: Ensure that parameters passed from JSP (like Strings) are correctly converted to the types expected by the jte template (like
Content or Enum). - Implement
TemplateOutput: Create a class implementing gg.jte.TemplateOutput (e.g., JspWriterOutput) that writes the rendered jte content directly to the javax.servlet.jsp.JspWriter. - Register the tag in your TLD file so the application recognizes the bridging tag name.
This allows your application to remain fully functional even when only a portion of the templates have been migrated to jte.
<!-- Example TLD registration for a bridging tag named 'jte' -->
<tag>
<name>jte</name>
<tag-class>my.JteTag</tag-class>
<body-content>scriptless</body-content>
<attribute>
<name>jte</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<dynamic-attributes>true</dynamic-attributes>
</tag>