JSP + XML:DB Guestbook

<%@ page import="org.xmldb.api.*,org.xmldb.api.base.*,org.xmldb.api.modules.*" %>
<%@ page import="java.util.Date" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%!
	// ------------------------------------------------------------------
	// Change these details
	// ------------------------------------------------------------------
	private String dbURI  = "xmldb:sedna://localhost/db";
	private String dbUser = "SYSTEM";
	private String dbPass = "MANAGER";
	// ------------------------------------------------------------------

	static final String GB_COLLECTION = "guestbook";
	SimpleDateFormat xsdDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
	Database sednaDatabase = null;

	public void registerDriver() throws Exception
	{
		if(sednaDatabase == null) {
			sednaDatabase = (Database)(Class.forName("net.cfoster.sedna.DatabaseImpl").newInstance());
			DatabaseManager.registerDatabase(sednaDatabase);
		}
	}

	public void ensureGuestbookCollectionExists() throws XMLDBException
	{
		Collection root = DatabaseManager.getCollection(dbURI, dbUser, dbPass);
		Collection gbookCol  = root.getChildCollection(GB_COLLECTION);
		if(gbookCol == null) { // doesn't exist
			CollectionManagementService cms = (CollectionManagementService)root.getService("CollectionManagementService","1.0");
			cms.createCollection(GB_COLLECTION);
		}
		root.close();
	}

	public String makeXMLSafe(String string) {
		return string.replaceAll("<","&lt;").replaceAll(">","&gt;").trim();
	}

	public String getXSDDateTimeFromDate(Date date) {
		return xsdDateFormat.format(date);
	}
%>
<%
	registerDriver();
	ensureGuestbookCollectionExists();

	String name    = request.getParameter("name");
	String email   = request.getParameter("email");
	String message = request.getParameter("message");

	if(name != null) // Has signed guestbook
	{
		if(name.trim().length()==0)          out.println("<div class='error'>Must give a name.</div>");
		else if(message.trim().length()==0)  out.println("<div class='error'>Must write a message.</div>");
		else // signed it ok
		{
			Collection gbookCol = DatabaseManager.getCollection(dbURI+"/"+GB_COLLECTION, dbUser, dbPass);
			XMLResource res = (XMLResource)gbookCol.createResource(null, "XMLResource");

			res.setContent("<message>"+
  			               "<timestamp>" + getXSDDateTimeFromDate(new Date()) + "</timestamp>" +
			                 "<name>" + makeXMLSafe(name) + "</name>" +
			                 "<email>" + makeXMLSafe(email) + "</email>" +
			                 "<content>" + makeXMLSafe(message) + "</content>" +
			               "</message>");
			gbookCol.storeResource(res);
			gbookCol.close();
		}
	}

%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-GB" lang="en-GB">

	<head>
		<title>Simple JSP Guestbook</title>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<link href="style.css" type="text/css" rel="stylesheet" />
	</head>

	<body>

		<div class="x-body">

			<h1>Please sign the guestbook!</h1>

			<form method="post" action="">

				Your Name:
					<input type="text" name="name" />
				Your E-Mail Address:
					<input type="text" name="email" />
				Your Message:
					<textarea name="message" rows="20" cols="52"></textarea>

					<inpu