| This is a simple servlet program, mainly designed to capture the lastname of all users in names. nsf and show it on the browser.
Environment Settings:
1. Installing jdk1.2.2 or later
2. Add the following JAR extension path to classpath:
> Jsdk (jsdk. Jar): Domino R5 currently provides the 2.0 version of jsdk, which is stored in the Project of Domino (or notes). You can also download the latest version from the sun website.
> Domnio Java classes (notes. Jar): it is stored in the directory of Domino (or notes.
> Ncso. jar: If you want to use remote access, you must add this scheme, which is stored under \ data \ domino \ HTML \ Java.
3. Using Java Servlet for logging: Choose server files> Internet Communication Settings> Domino web engine> Java Servlets settings, as shown below:
Develop a program:
1. Use the text transfer history tool to compile the following programs and save them as shownames. Java
Import java. Io .*;
Import javax. servlet .*;
Import javax. servlet. http .*;
Import Lotus. Domino .*;
Public class shownames extends httpservlet {
Public shownames (){
Super ();
}
Public void doget (httpservletrequest req, httpservletresponse res ){
Try {
// Set up HTML output format
Res. setcontenttype ("text/html ");
Printwriter out = res. getwriter ();
Out. println ("
Out. println ("
Out. println ("<body> ");
// Initialize notes access and get the people view in loacl address book Notesthread. sinitthread ();
Session S = notesfactory. createsession (); Database DB = S. getdatabase (null, "names. nsf "); View vw = dB. getview ("people "); // Loop through each person document Document Doc = VW. getfirstdocument (); While (Doc! = NULL ){ Out. println (Doc. getitemvaluestring ("lastname") + "<br> "); Doc = VW. getnextdocument (DOC );
} // Finish off HTML document Out. println ("</body> } Catch (exception e ){ // Print out errors to console and Servlet log (servlet log output goes to notes log) E. printstacktrace (); Getservletcontext (). Log ("error:" + E. getmessage ()); } Finally { // Clean up notes Notesthread. stermthread (); } } }
2. zookeeper program: Use javacShownames. Java: shownames. Class
3. Deployment: Copy shownames. Class names to \ data \ domino \Servlet
4. Restart the HTTP service.
Start worker startup: start IE and import http: // localhost/servlet/shownames. have you listed all the members in the listener? ^
Appendix: usage of domnio Java classes. Please refer to Notes help
|