com.xmlserv.main
Class ErrorPage

java.lang.Object
  |
  +--com.xmlserv.main.ErrorPage

public class ErrorPage
extends java.lang.Object

An errorpage using a simple XML document plus a XSL stylesheet to output the error message. The error code can be used to provide licalized error messages (not currently supported in this implementation).

Version:
$Id: ErrorPage.java,v 1.11 2002/12/16 17:24:57 muecke Exp $
Author:
Wolfram Saringer

Constructor Summary
ErrorPage()
          Construct empty errorpage.
ErrorPage(java.lang.String msg)
          ErrorPage with a message string.
ErrorPage(java.lang.String msg, java.lang.String code)
          ErrorPage with message and error code.
ErrorPage(java.lang.String msg, java.lang.String code, java.lang.Exception e)
          ErrorPage with message and code, additional info is taken from the given Exception
 
Method Summary
 org.jdom.transform.JDOMSource getErrorPage()
           
 javax.xml.transform.Transformer getStylesheet(javax.servlet.ServletContext context)
          Get the ErrorPage XSL Stylesheet.
static void main(java.lang.String[] args)
          Test routine.
 void printHTML(javax.servlet.ServletContext context, java.io.PrintWriter outstream)
          Convert error document to HTML and print to given PrintStream.
 javax.xml.transform.Source toDocument()
          Create XML document from the error message and the error code.
 org.jdom.Element toElement()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ErrorPage

public ErrorPage()
Construct empty errorpage.

ErrorPage

public ErrorPage(java.lang.String msg)
ErrorPage with a message string. A default error code is supplied.
Parameters:
msg - The error message.

ErrorPage

public ErrorPage(java.lang.String msg,
                 java.lang.String code)
ErrorPage with message and error code. Error codes have the following form:
<negative number>: <textual code
The error textual code is all upper case without spaces to facilitate parsing.
Parameters:
msg - The error message.
code - The error code.

ErrorPage

public ErrorPage(java.lang.String msg,
                 java.lang.String code,
                 java.lang.Exception e)
ErrorPage with message and code, additional info is taken from the given Exception
Parameters:
msg - The error message
code - The error code
e - The Exception to describe
Method Detail

toElement

public org.jdom.Element toElement()

toDocument

public javax.xml.transform.Source toDocument()
Create XML document from the error message and the error code.
Returns:
The XML document.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getStylesheet

public javax.xml.transform.Transformer getStylesheet(javax.servlet.ServletContext context)
                                              throws java.net.MalformedURLException,
                                                     java.io.IOException,
                                                     javax.xml.transform.TransformerConfigurationException
Get the ErrorPage XSL Stylesheet.
Parameters:
context - The ServletContext used to locate the stylesheet.
Returns:
The Stylesheet.

printHTML

public void printHTML(javax.servlet.ServletContext context,
                      java.io.PrintWriter outstream)
Convert error document to HTML and print to given PrintStream.
Parameters:
context - The servlet context.
outstream - The outputstream to write to.

getErrorPage

public org.jdom.transform.JDOMSource getErrorPage()

main

public static void main(java.lang.String[] args)
Test routine.