/* ======================================================================
   Parts Copyright 2006 University of Leeds, Oxford University, University of the Highlands and Islands.

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

====================================================================== */

package org.bodington.servlet.template;

import org.bodington.servlet.*;
import org.bodington.servlet.template.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

/**
 * @author  bmb6jrm
 */
public class XmlTemplateErrorProcessor extends XmlTemplateProcessor
{
    
    String error_message=null;
    
    /** Creates new XmlTemplateErrorProcessor */
    public XmlTemplateErrorProcessor()
    {
    }
    
    public XmlTemplateErrorProcessor( String message )
    {
	error_message = message;
    }
    
    public void process(org.bodington.servlet.Request request, org.bodington.servlet.Response response)
    throws java.io.IOException, javax.servlet.ServletException
    {
	PrintWriter writer = response.getWriter();
	
	writer.println( "<html><head><title>Invalid Template</title></head>" );
	writer.println( "<body>" );
	writer.println( "<p>The requested page can't be delivered because the template file" );
	writer.println( "contains errors.  This is a system administration problem.</p>" );
	if ( error_message != null )
	{
	    writer.println( "<H4>Error Message</h4>" );
	    writer.println( "<p>" );
	    writer.println( error_message );
	    writer.println( "</p>" );
	}
	writer.println( "</body></html>" );
    }
    
}
