lotus中的邮件转向 MailRedirectServlet

是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的目录下,启动服务器,

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值