Open in new window

back

Creating Custom JSP Templates

When creating a new JSP page, you can base the new page on a pre-existing template instead of a blank page. The template can contain common header/footer information for the page or really anything you want.

Separate sets of JSP page templates are associated with the different types of project you work on. The types of projects are:

  • JSF
  • Struts

Saving JSP Page as a Template

Switch to WebProjects view and right click any JSP page. Select Save as Template....

jspTemplateJSF0

Click Ok to create a template based on this page.

Using Preference Settings to Create a Template

Creating your own template based on a page that you have created within one of your projects in your Eclipse workspace is pretty easy.

  1. Open the Preferences panel by selecting Windows/Preferences from the menu bar.
  2. Navigate to the Exadel/JSF/JSF Pages or Exadel/Struts/Struts Pages section.
  3. Click on the Add button to the right of the template list.
  4. In the dialog box that appears, type in a name for the template and then use the Browse... button to select the location of the page you want to make into a template.
The location should be located within a project. (Once this is done it doesn't matter if you delete the original JSP page or the project containing it.)

TemplatePreference

Creating a JSP Page with a Template

JSF

  1. In the Project Explorer view select the folder where you want to create JSP file.
  2. Right click>New>JSP File (or in the Web Projects view, right click>New>File>JSP File)
  3. Expand Template field and select the template.

JSFBasePage

JSPRedirect

Struts

StrutsForm

Using the File System to Create a Template

Alternatively, you can create the template outside of Eclipse. Just open this folder:

<eclipse>\plugins\com.exadel.project.templates_X.X.X\templates
Create a text file with the coding you want for the template. Name the file exactly as you want the template name to appear. Then, place the file inside the appropriate folder for the project type (jsf or struts). Or, place the file at the same level as the Blank file for the template to be available to either project type.

After you restart Eclipse, your template will be available.

back