Discussion:
Accessing Lotus Notes database from a servlet.
(too old to reply)
gauz09
2004-06-15 16:35:13 UTC
Permalink
Hi all,

How can Lotus Notes databases be accessed from a servlet or JavaBean? Any help will be highly appreciated.

Thanks in advance...

Gauzy
M***@hpigmbh.com
2004-06-16 09:30:13 UTC
Permalink
This requires the nsco.jar file (found in the data/domino/java directory
of the client).

and then :

package com.hpigmbh.fleetReporting.presentation.actions;

import java.io.IOException;

import javax.servlet.Servlet;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import lotus.domino.Database;
import lotus.domino.Document;
import lotus.domino.DocumentCollection;
import lotus.domino.NotesException;
import lotus.domino.NotesFactory;
import lotus.domino.NotesThread;
import lotus.domino.Session;

public class notesTest extends HttpServlet implements Servlet {

public void doGet(HttpServletRequest req, HttpServletResponse
resp) throws ServletException, IOException {

try {
NotesThread.sinitThread();
Session notesSession = NotesFactory.createSession(
"hostString", "userString", "passwordString");
Database notesDatabase = notesSession.getDatabase(
"MyServer", "MyDatabase.NSF");
DocumentCollection notesCollection =
notesDatabase.getAllDocuments();
Document notesDocument =
notesCollection.getFirstDocument();
// And so on
}
catch (NotesException e) {
e.printStackTrace();
}
finally {
NotesThread.stermThread();
}

}

public void doPost(HttpServletRequest req, HttpServletResponse
resp) throws ServletException, IOException {

}

}


if you're into notes development, the rest is easy as known from notes
script
gauz09
2004-06-16 15:11:45 UTC
Permalink
Thanks Matthias for posting your example. That will surely help me to start with. I will try it and let you know if I am stuck :)

Thanks again.

Gauzy

steve
2004-06-16 12:47:02 UTC
Permalink
gauz09 <***@yahoo.com> wrote in message news:<***@swg3ws006>...

depending on what version of notes you are using get the NCSO.jar or
NCSOW.jar file. Then use the following methods.

// connect to the domino server

Session sess;
sess = NotesFactory.createSession(host, user, password);

// open the database

Database db;
db = sess.getDatabase(server, dbFileName, false);
if (!db.isOpen()) {
db.open();
}
// close when done. Very important
db.recycle( )

// close when done. Very important
sess.recycle( )


Your Domino server needs to be running DIIOP. It will also need to be
running HTTP if you connect using the above API calls. If you can get
access to the Domino Designer application it has a whole help section
on writing java based apps.
Post by gauz09
Hi all,
How can Lotus Notes databases be accessed from a servlet or JavaBean? Any help will be highly appreciated.
Thanks in advance...
Gauzy
Loading...