Hola Amigos. Tengo este código y no quiere ser compilado:
package testservlets;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import com.xmlmill.*;
import com.xmlmill.config.Configurator;
public class Fetch extends HttpServlet
{
public void init(ServletConfig config) throws ServletException
{
// necessary to initialize servlet on IAS.
super.init(config);
// Following actions :
// 1. Call configurator
// 2. Set LogFile
// 3. Set LogLevel
// should only be done in ONE servlet (if you have more
// servlets calling XMLMill's PDXTransform method).
// All servlets using PDXTransform instances will
// use the same Logger; hence write the logmessages
// in the same logfile and will have the same loglevel.
try {
// Set Configurator.
// Although this is optional it will force XMLMill to
// get a ClassLoader instance. Some application servers
// have difficulty in finding a ClassLoader instance after
// the servlet is initialized. Hence we do it here.
Configurator.configure();
// Get the realpath.
// This is necessary to set the logfile.
//this.realpath = this.getServletContext().getRealPath("/xmlxsl/");
realpath = this.getServletContext().getRealPath("/xmlxsl/");
// Set the Logfile
// Resin 2.1.0
//File logfile = new File(realpath+"log/xmlmill_"+(newDate()).getTime()+".log");
// Tomcat 4.0.4
File logfile = new File(realpath+"/log/xmlmill_"+(newDate()).getTime()+".log");
PDXLogger.setPDXLogFile(logfile);
// Set LogLevel
PDXLogger.setLevel("DEBUG");
} catch (Exception e) {
throw new ServletException(e);
}
}
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
String realpath = this.getServletContext().getRealPath("/xmlxsl/");
PDXTransform transform;
try
{
// Tomcat 4.0.4 server
File xmlfile = new File(realpath + "/" +request.getParameter("xml"));
File xslfile = new File(realpath + "/" +request.getParameter("xsl"));
// Mimic xml-stream and xsl-stream
FileInputSteam xmlstream = new FileInputSteam(xmlfile);
FileInputSteam xslstream = new FileInputSteam(xslfile);
// Set ContentType ¹
response.setContentType("application/pdf");
//Get the output stream
javax.servlet.ServletOutputStream ostream = response.getOutputStream();
// Define an errorhandler(optional)
PDXTransformErrorHandler ehandler = new PDXTransformErrorHandler(
PDXTransformErrorHandler.ABORT_ON_ERROR );
// Define a tranform object
PDXTransform transform = new PDXTransform();
// Set the xml file
transform.setXMLStream(xmlstream);
// Set the xsl file
transform.setXSLStream(xslstream);
// Define where xmlmill.dtd resides on the server
transform.setXMLSystemId(xmlfile);
// Define where images and other resources resides on the server
transform.setXSLSystemId(xslfile);
// Set the errorhandler
transform.setErrorHandler(ehandler);
// Set transform outputstream
transform.setOutputStream(ostream);
// Log the xslfile-name (just as an example how to log)
PDXLogger.getPDXLogger().debug("Start transformation...");
// Check if the client is IE.
String useragent = request.getHeader("User-Agent");
if ((useragent != null) && (useragent.indexOf("MSIE") != -1))
transform.setDocumentSize(8192);
// and transform.
transform.transform();
// Set contentlength.
response.setContentLength(transform.getDocumentSiz e());
// Close stream
ostream.flush();
ostream.close();
// Flush response buffer
response.flushBuffer();
} catch (Exception e){
PDXLogger.getPDXLogger().debug("Catch-error:" + e.getMessage());
}
//public void destroy() {
// Reset the errorlog to the standard error log.
// This should only be done in ONE servlet.
//PDXLogger.resetErrorLog();
//}
}
}
Errores:
cannot resolve symbol:
variable realpath
method new date
entre otros
Gracias por la ayuda!!!