Thanks to Luis Gois for answering
it now says:
"No method matching main() found in inner class org.apache.cocoon.www.pages.make1_xsp. make_xsl."
I really don't know why there is a space between make1_xsp. and  make_xsl. Is it normal?
 
*******
Here is my code for make1.xsp
*******
<?xml version="1.0" encoding="ISO-8859-1"?>
 
<xsp:page
          language="java"
          xmlns:xsp="http://apache.org/xsp"
          xmlns:esql="http://apache.org/cocoon/SQL/v2">
 
<xsp:structure>
  <xsp:include>java.io.*</xsp:include>
</xsp:structure>
 
<xsp:logic>
class make_xsl {
  public void main(String[] args) throws IOException {
 FileReader entree = new FileReader(("http//:localhost/cocoon/test/make.xsl"));
  FileWriter sortie = new FileWriter("output.txt");
 int c;
 while ( (c = entree.read()) != -1 )            
sortie.write(c);            
sortie.close();        
entree.close();     
     }
}
</xsp:logic>

  <page>
 
<xsp:logic>
    make_xsl anObject = new make_xsl();
    anObject.main();
</xsp:logic>
 
If you see this, it works.
  </page>
</xsp:page>
 
 
Surely I didn't put the anObject call at the right place. My java is rather experimental.
Thanks again.
 
*******
I ADD THE CODE OF make1_xsp.java (I strip the code of usual imports):
*******
 
 
package org.apache.cocoon.www.pages;
import java.io.*;

/**
 * Generated by XSP. Edit at your own risk, :-)
 */
public class make1_xsp extends XSPGenerator {
 
  static {
    dateCreated = 1000658859410L;
    dependencies = new File[]{
                   };
  }
 
  /* Built-in parameters available for use */
  // context    - ServletContext
  // request    - HttpServletRequest
  // response   - HttpServletResponse
  // parameters - parameters defined in the sitemap
 
  /* User Class Declarations */
 
  class EsqlConnection {
 
    Connection connection = null;
    String dburl = null;
    java.util.Properties info = new java.util.Properties();
    int use_limit_clause = 0;
    static final int LIMIT_CLAUSE_POSTGRESQL = 1;
    static final int LIMIT_CLAUSE_MYSQL = 2;
  }
  class EsqlQuery {
    String query;
    Statement statement;
    PreparedStatement prepared_statement;
    ResultSet resultset;
    ResultSetMetaData resultset_metadata;
    /** the position of the current row in the resultset **/
    int position = -1;
    int max_rows = -1;
    int skip_rows = 0;
    boolean results;
  }
 
  private final String getAscii(ResultSet set, String column) {
    InputStream asciiStream = null;
    byte[] buffer = null;
 
    try {
      Clob dbClob = set.getClob(column);
      int length = (int) dbClob.length();
      asciiStream = new BufferedInputStream(dbClob.getAsciiStream());
      buffer = new byte[length];
      asciiStream.read(buffer);
      asciiStream.close();
    } catch (Exception e) {
      throw new RuntimeException("Error getting clob data: " +
                                 e.getMessage());
    }
    finally { if (asciiStream != null)
              try {
                  asciiStream.close();
              } catch (Exception ase) {
                  throw new RuntimeException(
                    "Error closing clob stream: " + ase.getMessage());
                }
            }
    if (buffer == null)
      return "";
 
    return new String(buffer);
  }
 
  class make_xsl {
    public void main(String[] args) throws IOException {
      FileReader entree = new FileReader(("http//:localhost/cocoon/test/make.xsl"));
      FileWriter sortie = new FileWriter("output.txt");
      int c;
      while ((c = entree.read()) != -1)
        sortie.write(c);
      sortie.close();
      entree.close();
    }
  }
 

  /**
   * Generate XML data.
   */
  public void generate() throws SAXException {
    this.contentHandler.startDocument();
    AttributesImpl xspAttr = new AttributesImpl();
 
 
 
    this.contentHandler.startPrefixMapping("xspdoc", "http://apache.org/cocoon/XSPDoc/v1");
 
    this.contentHandler.startPrefixMapping("esql", "http://apache.org/cocoon/SQL/v2");
 
    this.contentHandler.startPrefixMapping("xsp", "http://apache.org/xsp");
 

    this.contentHandler.startElement("", "page", "page", xspAttr);
 
    xspAttr.clear();
 

    Stack _esql_connections = new Stack();
    EsqlConnection _esql_connection = null;
    Stack _esql_queries = new Stack();
    EsqlQuery _esql_query = null;
    SQLException _esql_exception = null;
    StringWriter _esql_exception_writer = null;
 
    this.characters("\n\n");
 
    make_xsl anObject = new make_xsl();
    anObject.main();
 
    this.characters("\n\nIf you see this, it works.\n  ");
 

    this.contentHandler.endElement("", "page", "page");
 

    this.contentHandler.endPrefixMapping("xspdoc");
 
    this.contentHandler.endPrefixMapping("esql");
 
    this.contentHandler.endPrefixMapping("xsp");
 

    this.contentHandler.endDocument();
  }
}
 

 
----- Original Message -----
From: Luis Gois
Sent: Sunday, September 16, 2001 8:26 PM
Subject: Re : Xsp logic simpler error

You've made an inner class but you're calling it as a method!
 
Try this :
 
<xsp:logic>
    make_xsl anObject = new make_xsl();
    anObject.main();
</xsp:logic>
 
you main() method won't be called as you instatiate your make_xsl class, like it would happen if this was your program's starting/main class.
 
Luis Gois

Reply via email to