Re: JSP, JavaBeans and Xindice

"Lisa McCabe" <[email protected]>
Newsgroups gmane.text.xml.xindice.user
Message-ID <000a01c59134$81c51170$8ed3d442@MegaCool>
Hi Marcin,

Here is my code:

package org.isetools;

import org.xmldb.api.base.*;
import org.xmldb.api.modules.*;
import org.xmldb.api.*;
import java.io.*;
public class XindiceBean {


public String callDB(String xpath) throws Exception {

Collection collection = null;

StringBuffer myResult = new StringBuffer();

try {

String driver = "org.apache.xindice.client.xmldb.DatabaseImpl";

Class c = Class.forName(driver);

Database database = (Database) c.newInstance();

database.setProperty("false", "true");

DatabaseManager.registerDatabase(database);

String uri = "xmldb:xindice-embed://localhost:8080/db/xml/metadata"; 

collection = DatabaseManager.getCollection(uri);


XPathQueryService service = (XPathQueryService) collection.getService("XPathQueryService", "1.0");


ResourceSet resourceSet = service.query(xpath);

ResourceIterator resourceIterator = resourceSet.getIterator();

while (resourceIterator.hasMoreResources()) {

Resource resource = resourceIterator.nextResource();

myResult.append((String) resource.getContent());

}

} catch (Exception e) {

System.err.println("XML:DB Exception occured ");

} finally {

if (collection != null) {

collection.close();

}

}

String text = myResult.toString();

return text;

}

}

Thanks for taking a look! My JSP page calls this bean, sending it the xpath query. I hope to manipulate the results with JSTL.

-Lisa McCabe



  ----- Original Message ----- 
  From: Marcin Goldyn 
  To: [email protected] 
  Sent: Monday, July 25, 2005 9:53 AM
  Subject: Re: JSP, JavaBeans and Xindice


  there can be a plenty of reasons 
  show us the code 
  Marcin Goldyn
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.