<%@page contentType="text/xml;charset=UTF-8" pageEncoding="ISO-8859-1" isErrorPage="true" session="true"
%><%@page import="com.fujitsu.iflow.common.DOMUtils"
%><%@page import="java.io.*"
%><%@page import="java.io.ByteArrayOutputStream"
%><%@page import="java.util.Enumeration"
%><%@page import="javax.xml.transform.Transformer"
%><%@page import="javax.xml.transform.TransformerFactory"
%><%@page import="javax.xml.transform.dom.DOMSource"
%><%@page import="javax.xml.transform.stream.StreamResult"
%><%@page import="org.w3c.dom.Document"
%><%@page import="org.w3c.dom.Element"
%><%
    request.setCharacterEncoding("UTF-8");request.getParameterNames(); //Need dummy call for WL9.1

    Document doc = DOMUtils.createDocument();
    Element rootEle = doc.createElement("exception");
    doc.appendChild(rootEle);

    DOMUtils.createChildElement(doc, rootEle, "userName",
        (String)session.getAttribute("userName"));
    DOMUtils.createChildElement(doc, rootEle, "hostName",
        (String)session.getAttribute("hostName"));
    DOMUtils.createChildElement(doc, rootEle, "protocol",
        (String)session.getAttribute("protocol"));
    DOMUtils.createChildElement(doc, rootEle, "time",
        (new java.util.Date()).toString());

    if (exception == null) {
        DOMUtils.createChildElement(doc, rootEle, "message",
           "Unknown Exception -- The exception message was lost before generating this XML.");
    }
    else {
        DOMUtils.createChildElement(doc, rootEle, "message",
            exception.toString());
    }


    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    DOMSource docSource = new DOMSource(doc);
    TransformerFactory tf = TransformerFactory.newInstance();
    Transformer transformer = tf.newTransformer();
    transformer.transform(docSource, new StreamResult(baos));
    out.write(baos.toString("UTF-8"));
    out.flush();

%>

