You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-dev@xmlgraphics.apache.org by Rabi Shanker <ra...@hotmail.com> on 2002/08/22 16:29:10 UTC
Re: Embedding FOP in servlet
well this code is not mine. i got it from the site http://xml.apache.org/
hope his works.
these are the steps that i used for tomcat
1.put the FopServlet.class in
tomcat/webapps/examples/web-inf/classes/org/apache/fop/tools/servlet
2.add the following to the web.xml in the conf directory of the tomcat
<servlet>
<servlet-name>
Fop
</servlet-name>
<servlet-class>
org.apache.fop.tools.servlet.FopServlet
</servlet-class>
</servlet>
3.put the fo file in the tomcat/fop/example directory
4.add fop.jar and w3c.jar to the lib directory of tomcat
5.call the fo file throught the browser
http://servername/servlet/FopServlet?fo=/fullpath_to_tomcat/fop/example/read
me.fo
and u will get readme.pdf displayed.
u can do according to ur web server. i dont think that step 2 is requred if
it is not tomcat.
all the best.
do tell me if it works.
cheers!!!
Rabi
---------------------
------------------------xmltofoservlet.java------------------------
import java.io.*;
//import xmltofo.transfer;
import javax.servlet.*;
import javax.servlet.http.*;
import org.apache.xalan.xslt.*;//newly added
/**
* Example servlet to generate a fo file from xml and xsl files.
*/
public class XmltoFopServlet extends HttpServlet
{
public void doGet(HttpServletRequest request, HttpServletResponse
response)
throws ServletException , IOException
{
java.io.PrintWriter out = new
java.io.PrintWriter(response.getOutputStream());
response.setContentType("text/html");
try
{
/*transfer.Transform("http://localhost:8080/examples/biabgrun.xml","http://l
ocalhost:8080/examples/biabgrun.xsl","http://localhost:8080/examples/biabgru
n.fo");
transfer.Transform("D:\e-BI\jakarta-tomcat-3.2.1\webapps\examples\rs.xml","D
:\e-BI\jakarta-tomcat-3.2.1\webapps\examples\rs.xsl","D:\e-BI\jakarta-tomcat
-3.2.1\webapps\examples\rs.fo");
out.println("<HTML>");
out.println("<BODY>");
out.println("<B>Transformation is done<B>");
out.println("<BODY>");
out.println("<HTML>");*/
//newly added
org.apache.xalan.xslt.XSLTProcessor processor =
org.apache.xalan.xslt.XSLTProcessorFactory.getProcessor();
org.apache.xalan.xslt.XSLTInputSource xmlSource =
new org.apache.xalan.xslt.XSLTInputSource
("http://localhost:8080/examples/rs.xml");
org.apache.xalan.xslt.XSLTInputSource xslSheet =
new org.apache.xalan.xslt.XSLTInputSource
("http://localhost:8080/examples/rs.xsl");
org.apache.xalan.xslt.XSLTResultTarget xmlResult =
new org.apache.xalan.xslt.XSLTResultTarget
("http://localhost:8080/examples/rs.fo");
processor.process(xmlSource, xslSheet, xmlResult);
}
catch (Exception ex)
{
System.out.println(ex);
}
}
}
>From: "siva" <si...@questech.co.in>
>To: fop-dev@xml.apache.org, www-xsl-fo@w3.org
>Subject: Embedding FOP in servlet Date: Wed, 21 Aug 2002 07:01:49 -0400
>(EDT)
>
>
>
>
>
>Hi friends,
>
>I'm new to FOP, I have requirement to generate PDF file from XML & XSL...
>I have down loaded fop.0.20.4, trying to use FopServlet.java on tomcat3.2.2
>but it throws lot of errors, inspite of following the procedure given in
>the
>docs... I'am not able to understand it...
>
>So, If anybody have implemented Embedding FopServlet.java on tomcat3.2.2
>please help me...
>
>thanks in advance
>-Siva
>
>
>_____________________________________________________________________
>Any Opinions, explicit or implied, are solely those of the author and do
>not necessarily
>represent those of Questech. This e-mail may contain confidential and/or
>privileged
>information. If you are not the intended recipient (or have received this
>e-mail in error)
>please notify the sender immediately and destroy this e-mail. Any
>unauthorized copying,
>disclosure or distribution of the material in this e-mail is strictly
>forbidden.
>_____________________________________________________________________
_________________________________________________________________
Join the worlds largest e-mail service with MSN Hotmail.
http://www.hotmail.com
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
For additional commands, email: fop-dev-help@xml.apache.org