What is an Eclipse template and how do I use it?
Author: Deron Eriksson
Description: This tutorial shows how to use a template in Eclipse
Tutorial created using: Windows XP || JDK 1.5.0_09 || Eclipse Web Tools Platform 1.5.1


Page: < 1 2

(Continued from page 1)

Back on the Preferences window, we can see our new template in the list of JSPW templates, and we can see a preview of the template in the 'Preview' textbox. We can click 'Apply' and 'OK' to close the Preferences window.

Preview of JSP Template

I created a new test JSP called blah.jsp. At the very beginning of the JSP (since the template that we created has the 'New JSP' context), we can hit control-space to bring up the auto-complete popup list. If we scroll down this list, we can see our new 'jstl header' template in the list.

New JSP Template shown in auto-complete

If we select 'jstl header' from the auto-complete list, our new template gets inserted into our JSP. Notice that the ${encoding} variable has been converted to ISO-8859-1.

JSP Template inserted via auto-complete

As you can see, EclipseSW templates are a GREAT way to speed up your coding by automating repetitive tasks. In fact, this tutorial was created using an Eclipse JSP template.

Page: < 1 2