Calling a Java Class

How do I call this from a servlet?

publicclass JSPRunReport

{

publicstaticvoid main(String args[])

{

FileOutputStream fileout =null;

/** specify the URL that contains the data you want to use in your report **/

String JSPurl = args[0];

URL jspurl =null;

try{

jspurl

[714 byte] By [SLDykea] at [2007-11-27 8:34:30]
# 1

Make it a proper class. Give it a constructor and methods that take the info it needs instead of commandline params.

public class JSPRunReport {

public void printReport(String jspurl) {

FileOutputStream fileout = null;

/** specify the URL that contains the data you want to use in your report **/

//String JSPurl = args[0];

URL jspurl = null;

try {

jspurl

// etc.

Then in your servlet code create a JSPRunReport object and call the appropriate methods.

hunter9000a at 2007-7-12 20:30:46 > top of Java-index,Java Essentials,New To Java...
# 2

I got that done now I get an error:

[6/22/07 13:05:06:146 CDT] 0000002d SystemOutO Ready to parse XSL document

[6/22/07 13:05:06:162 CDT] 0000002d ServletWrappe ESRVE0068E: Could not invoke the service() method on servlet ReportProcesserServlet. Exception thrown : java.lang.NoClassDefFoundError: org/apache/xerces/framework/XMLParser

Code the error is thrown on

/** create the JSPReportProcessor object and set the template to the specified JSP **/

JSPReportProcessor jspprocessor = new JSPReportProcessor(pdfcontext);

try {

jspprocessor.setTemplate(jspurl);

}

catch (NullPointerException np){

String mes = np.getMessage();

System.out.println(mes);

System.exit(0);

}

SLDykea at 2007-7-12 20:30:46 > top of Java-index,Java Essentials,New To Java...
# 3
I think that means you don't have the org.apache.xerces.framework package on the servlet's classpath, but I'm not positive.
hunter9000a at 2007-7-12 20:30:46 > top of Java-index,Java Essentials,New To Java...