Your application does not care - at least at this stage - whether it is 
accessed via IE or any other browser.

When your servlet is accessed, either through the init method or through 
post/get methods, you want your database to be connected to ; consequently 
you provide the servlet a driver class, in the present case a driver that 
implements xmldb with Xindice.
If you want your servlet to be able to load this driver, it must first find 
it. Depending on the java dev kit you use, several locations are possible.
In tomcat, a standard location can be
webapps/your_application/WEB_INF/lib
But other places are possible, for instance for tomcat-4.1.12 :
$TOMCAT_HOME/shared/lib.
You can also start tomcat with a script that provides a class path containing 
this driver class.



On Monday 27 January 2003 08:28, FTL Africa wrote:
> Thank you very much for the help.
>
> Can you please help me on the following.
> How do I make my program find the "driver" class?
> Which files do I have to alter to have the driver seen from the IE?
> Please take note that when I am in the same directory, that contains both
> servlet class and non-servlet class, and run the non-servlet class from
> command line it runs, but when I try accessing the servlet version of the
> program it then fails.
>
> Regards
> Alisemore Dudzai Ndowora
>
> ----- Original Message -----
> From: jmt <[EMAIL PROTECTED]>
> To: <[email protected]>; FTL Africa <[EMAIL PROTECTED]>
> Sent: Friday, January 24, 2003 7:16 PM
> Subject: Re: ACCESSING DATABASE THROUGH SERVLET CALLED FROM INTERNET
> EXPLORER
>
> > This is caused by your program not finding the "driver" class. Your
> > web-application should contain a directory "lib" where it could find the
> > driver, or you could start your application container in a way its
>
> CLASSPATH
>
> > points to it.
> >
> > jmt
> >
> > On Friday 24 January 2003 18:08, FTL Africa wrote:
> > > Hi!
> > >
> > > I am having an error message:
> > >  Error: Error org.apache.xindice.client.xmldb.DatabaseImpl
> > > when the my program gets to:
> > >  Class c = Class.forName(driver);
> > >
> > > I am accessing the program from IE browser not command line
> > >   as is the case with the example RetrieveDocument.java.
> > > I wrote the following code following the example RetrieveDocument.java
>
> that
>
> > > came with xindice:
> > >
> > > import java.io.*;
> > > import javax.servlet.*;
> > > import javax.servlet.http.*;
> > > import org.xmldb.api.base.*;
> > > import org.xmldb.api.modules.*;
> > > import org.xmldb.api.*;
> > > import org.w3c.dom.*;
> > >
> > > public class XindiceServlet7 extends HttpServlet {
> > >
> > >     // The method corresponding to HTTP GET
> > >     public void doGet(HttpServletRequest request, HttpServletResponse
> > > response)
> > >         throws ServletException, IOException {
> > >          Collection col = null;
> > >          PrintWriter out = response.getWriter();
> > >             try {
> > >                 String driver =
> > > "org.apache.xindice.client.xmldb.DatabaseImpl";
> > >                 Class c = Class.forName(driver);    /* exception from
> > > here*/
> > >
> > >                  Database database = (Database) c.newInstance();
> > >                  DatabaseManager.registerDatabase(database);
> > >                  col =
> > >
> > > DatabaseManager.getCollection("xmldb:xindice:///db/addressbook");
> > >
> > >                  XMLResource document = (XMLResource)
> > > col.getResource("address");
> > >                  if (document != null) {
> > >                         out.println("Document ");
> > >                 } else {
> > >                         out.println("Document not found");
> > >                 }
> > >             } catch(Exception e) {
> > >                 out.write("Error " + e.getMessage());
> > >             }
> > >             finally {
> > >             }
> > >       }
> > > }
> > >
> > >
> > > Thanks in advance
> > >
> > > Alisemore Ndowora

Reply via email to