xml transform to pdf

Hello, i am trying to get the xml data from the database and transform it to pdf format. I don’t have any runtime error, but i don’t see anything in the browser. Can somebody help me to solve this Problem?
My Sourcecode seems like this:

import java.io.*;

import javax.servlet.;
import javax.servlet.http.
;

import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamSource;

import org.apache.avalon.framework.logger.ConsoleLogger;
import org.apache.avalon.framework.logger.Logger;
import org.apache.fop.apps.Driver;
import org.apache.fop.messaging.MessageHandler;

import org.jdom.Document;
import org.jdom.Element;
import org.jdom.transform.JDOMResult;
import org.jdom.transform.JDOMSource;

import com.softwareag.tamino.db.api.connection.* ;
import com.softwareag.tamino.db.api.accessor.* ;
import com.softwareag.tamino.db.api.objectModel.* ;
import com.softwareag.tamino.db.api.objectModel.jdom.* ;
import com.softwareag.tamino.db.api.response.* ;

/* Das ist ein Servlet mit pdf Output */

public class HelloTamino5 extends HttpServlet
{
private static final long serialVersionUID = -1961320101946993091L;
public static final String URL = “http://localhost/tamino/DBForschung”;
public static final String USER = “ming”;

public void doGet( HttpServletRequest requ, HttpServletResponse resp )
throws ServletException, IOException
{
resp.setContentType(“application/pdf”);
ByteArrayOutputStream out = new ByteArrayOutputStream();

TConnection tcon = null;
try
{
    tcon = TConnectionFactory.getInstance().newConnection (URL, USER , "");    
    TXMLObjectAccessor tacc = tcon.newXMLObjectAccessor (
    		TAccessLocation.newInstance("ForschDB"),
    		TJDOMObjectModel.getInstance() ) ;
    TQuery query = TQuery.newInstance ("/Abteilung") ;

    // Query for the resulting document(s)

    TResponse tresp = tacc.query (query) ;
    TXMLObjectIterator ti = tresp.getXMLObjectIterator() ;
    TXMLObject next = ti.next();
    Element element=(Element)next.getElement();
 
    element=element.detach();
    Document doc=new Document(element);
      
    Logger log = new ConsoleLogger(ConsoleLogger.LEVEL_WARN);
    MessageHandler.setScreenLogger(log);
    Driver driver = new Driver();
    driver.setLogger(log);
    driver.setRenderer(Driver.RENDER_PDF);
    driver.setOutputStream(out);

        
    Transformer transformer = TransformerFactory.newInstance().newTransformer(new StreamSource(new File("D:/fopdatein/xslt/abteilung2fo.xsl")));
	JDOMSource xmlsource = new JDOMSource(doc);
	JDOMResult result = new JDOMResult();  
	 
	transformer.transform(xmlsource, result);
	result.getDocument();
	resp.setContentLength(out.size());    
    resp.getOutputStream().write(out.toByteArray());
    resp.getOutputStream().flush();

   
}
catch (TConnectionException terr)
{
	System.out.println ("Sorry, database Forschdb is offline.") ;
}
catch (Exception e)
{
	System.out.println ("Application error") ;
    e.printStackTrace() ;
}
finally
{
    try
    {
        if (tcon != null && !tcon.isClosed())
            tcon.close ();
    }
    catch (Exception e)
    {
    	System.out.println ("Connection cannot be closed") ;
    }
}

}
}

Thanks in advance!
Ming

Hello,
I think the output of your transformation is not finding its way into the Driver for rendering. Try the following:

  1. Remove your statement “JDOMResult result = new JDOMResult();”
  2. Change your transform to:
    transformer.transform(xmlsource, new SAXResult(driver.getContentHandler()));
    You will need to adjust your import statements too.
    I hope this helps, but if not you can find some examples
    here

It works, thanks a lot!!!