How to Create a JavaServlet program in notes

Source: Internet
Author: User
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

Additional case

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.