BROWSE CATDV SUPPORT MANUALS

Java Server Pages are HTML pages that contain special tags that execute Java code on the server to query the CatDV database and insert data into the page. JSPs are processed by the Apache Tomcat servlet engine. JSPs are automatically compiled into Java servlets when they’re accessed for the first time. Although you can use normal HTML editing tools to customise the layout of JSP pages it is important to get the syntax of the tags correct otherwise you will get Java errors when you display the page.

The following are some of the special tags that will be encountered and are likely to be unfamiliar to most HTML authors:

<%@ taglib uri=”/WEB-INF/catdv.tld” prefix=”catdv” %>

This directive occurs at the top of each JSP that wants to use the CatDV tag library (special tags of the form <catdv:xxx> that perform particular functions, detailed below).

<%@ include file=”bodyStart.inc” %>

The include directive can be used to insert common HTML into the file, such as style sheets or JavaScript functions, so that all pages have a common appearance.

<form action=”searchDatabase.jsp” method=”POST”>

A JSP can be the target of a form that is submitted.

<% … %>

This is used to insert raw Java code. In general, you should not alter any of these from the examples provided in the sample JSPs as it’s very easy to introduce syntax errors that will prevent the page from compiling, eg. by misplacing a brace or accessing a variable that isn’t defined in a particular context.

<%= ….%>

This includes output from a Java expression in the HTML page that is being produced, for example a variable defined by a CatDV tag or declared in an earlier <%…%> statement.

<%= clip.get(“Name”) %>

This accesses the value of  a particular clip attribute.

<% if (condition) { %>

<% } else { %>

<% } %>

This example will conditionally include one or other piece of output. As noted previously, irrespective of the non-Java contents between the tags, if you want to avoid syntax errors it is vital that the braces continue to match!

<%! … %>

If you are familiar with Java you can define helper functions to carry out useful tasks such as formatting data for a table by placing your method definitions inside a global declaration tag like this.