thank you for u're patience,

those modifications you sent got me way closer to compiling weee,

ne ways,... here is my code for doget with the modifications you suggested.
I probably need to create some sort of driver object here cause it complains
about that and i don't think it likes sending xmlparam into new JDOMSource.
also, the call to renderXML doesn't work because input is not defined.  here
is the code and the errors generated by ant:

public void doGet(HttpServletRequest request,
                      HttpServletResponse response) throws ServletException
{
        if (log == null) {
            log = new ConsoleLogger(ConsoleLogger.LEVEL_WARN);
            MessageHandler.setScreenLogger(log);
        }
        try {
            String foParam = request.getParameter(FO_REQUEST_PARAM);
            String xmlParam = request.getParameter(XML_REQUEST_PARAM);
            String xslParam = request.getParameter(XSL_REQUEST_PARAM);

            if (foParam != null) {
                File fofile = new File(foParam);
                //log.warn("FO: "+fofile.getCanonicalPath());
                FileInputStream file = new FileInputStream(fofile);
                renderFO(new InputSource(file), response);
            } else if ((xmlParam != null) && (xslParam != null)) {
                                URL fileOpenServlet = new
URL("http://extranet.inland-group.net/vsearchnew/xsl/vehpdf.xsl";);
                HttpURLConnection servletConnection = (HttpURLConnection)
                fileOpenServlet.openConnection();
                InputStream xslInStream =
servletConnection.getInputStream();
                Transformer transformer =
TransformerFactory.newInstance().newTransformer(new
StreamSource(xslInStream));
                transformer.transform(new JDOMSource(xmlParam), new
SAXResult(driver.getContentHandler()));
                //XSLTInputHandler input =
                                //      new XSLTInputHandler(new 
File(xmlParam),xslInStream);
                renderXML(input, response);
            } else {
                PrintWriter out = response.getWriter();
                out.println("<html><head><title>Error</title></head>\n"+
                            "<body><h1>FopServlet Error</h1><h3>No 'fo' "+
                            "request param given.</body></html>");
            }
        } catch (ServletException ex) {
            throw ex;
        }
        catch (Exception ex) {
            throw new ServletException(ex);
        }
    }


    [javac] C:\fop-0.20.5rc2\examples\servlet\src\FopServlet.java:84: cannot
res
olve symbol
    [javac] symbol  : constructor JDOMSource (java.lang.String)
    [javac] location: class org.jdom.transform.JDOMSource
    [javac]                 transformer.transform(new JDOMSource(xmlParam),
new
SAXResult(driver.getContentHandler()));
    [javac]                                       ^
    [javac] C:\fop-0.20.5rc2\examples\servlet\src\FopServlet.java:84: cannot
res
olve symbol
    [javac] symbol  : variable driver
    [javac] location: class FopServlet
    [javac]                 transformer.transform(new JDOMSource(xmlParam),
new
SAXResult(driver.getContentHandler()));
    [javac]
          ^
    [javac] C:\fop-0.20.5rc2\examples\servlet\src\FopServlet.java:87: cannot
res
olve symbol
    [javac] symbol  : variable input
    [javac] location: class FopServlet
    [javac]                 renderXML(input, response);
    [javac]                           ^
    [javac] 3 errors

probably needs just a few tweaks, but like i said no clues to be found over
here hehe.

-Adam

-----Original Message-----
From: Jasmin Mehta [mailto:[EMAIL PROTECTED]
Sent: March 21, 2003 1:24 PM
To: [EMAIL PROTECTED]
Subject: RE: url to xml/xsl file in servlet


You need to add below imports in your code:

  import org.jdom.*;
  import org.jdom.transform.*;
  import org.jdom.transform.JDOMSource;
  import org.jdom.output.XMLOutputter;
  import org.jdom.input.SAXBuilder;

  import org.xml.sax.InputSource;
  import org.xml.sax.XMLReader;
  import javax.xml.transform.*;
  import javax.xml.transform.sax.*;
  import javax.xml.transform.stream.*;

You need to add JDOM library, i.e jdom.jar. And xalan.jar and xerces.jar
library too.

And than you can use below whole method in your fop servlet:

   public void renderXML(Document xmlsource, InputStream xslobj,
                         HttpServletResponse response) throws
ServletException {
   try {
          response.setContentType("application/pdf");
          Driver driver = new Driver();
          driver.setLogger(log);
          driver.setOutputStream(response.getOutputStream());
          driver.setRenderer(Driver.RENDER_PDF);
          Transformer transformer=TransformerFactory.newInstance()
                  .newTransformer(new StreamSource(xslobj));
          transformer.transform(new JDOMSource(xmlsource), new
SAXResult(driver.getContentHandler()));

        } catch (Exception ex) {
          //  throw new ServletException(ex);
          ex.printStackTrace();
          System.out.println("exception in fopservlet renderXML:
"+ex.getMessage());
        }
    }

}

Pl feel free to ask if you have any trouble. Because I have done so much
trial and error to get this work done. And I understand the troubles.

Jasmin

-----Original Message-----
From: Adam Shelley [mailto:[EMAIL PROTECTED]
Sent: Friday, March 21, 2003 4:10 PM
To: [EMAIL PROTECTED]
Subject: RE: url to xml/xsl file in servlet

Thank you for your reply.

What library do you need for the StreamSource class?

i copied the xml-apis from fop into the lib directory of the servlet and
added it to the build.xml file but it doesn't seem to like

import org.xml.transform.*;

it says package does not exist.  but i did see a streamsourceclass
within
the xml-apis.jar file so i dunno how to access it.

(please excuse me, i've never programmed java in my life this is all a
foriegn thing for me.  I just need to get this functionality up and
running
or else the security of my system with fop isn't gonna work. :( )

-Adam


-----Original Message-----
From: Jasmin Mehta [mailto:[EMAIL PROTECTED]
Sent: March 21, 2003 12:48 PM
To: [EMAIL PROTECTED]
Subject: RE: url to xml/xsl file in servlet


Please use


          Transformer transformer=TransformerFactory.newInstance()
                  .newTransformer(new StreamSource(xslInStream));
          transformer.transform(new JDOMSource(xmlsource), new
SAXResult(driver.getContentHandler()));

instead of XSLTInputhandler


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to