是servlet 写成的
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import lotus.domino.*;
public class MailRedirectServlet extends HttpServlet {
private String server = null;
private String dbname = "names.nsf";
public String getServletInfo() {
return "This servlet redirects users to their own mailfile.";
}
public void service(HttpServletRequest request, HttpServletResponse response) throws IOException {
if (request.getRemoteUser() == null) {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("Please create a File Protection document.");
} else {
NotesThread.sinitThread();
try {
Session session = NotesFactory.createSession();
Database db = session.getDatabase(server, dbname);
View view = db.getView("($Users)");
Document doc = view.getDocumentByKey(request.getRemoteUser().toLowerCase());
String mailfile = ((String) doc.getItemValue("MailFile").elementAt(0)).replace('\\', '/');
if (!mailfile.endsWith(".nsf"))
mailfile += ".nsf";
response.sendRedirect(response.encodeRedirectUrl(request.getScheme() + "://" + request.getServerName() + "/" + mailfile));
session.recycle();
} catch (NotesException ne) {
System.out.println(ne.id + " " + ne.text);
} finally {
NotesThread.stermThread();
}
}
}
}
在eclipse或着jbuilder下编译后,放在lotus的目录下,启动服务器,
本文地址:http://com.8s8s.com/it/it27106.htm