在Web上登录Domino后直接打开用户的邮件

4 篇文章 0 订阅

/**
 * <p>Title: MailRedirectServlet</p>
 * <p>Description: 登录Domino服务器后直接打开用户的邮件!</p>
 * <p>前提Domino配置成支持servelt,</p>
 * <p>打开Names.nsf,配置,服务器文档,Internet协议,Domino Web引擎,Java 服务器小程序,选择:Domino 服务器小程序管理器</p>
 * <p>保存后重启Domino</p>
 * <p>把这个编译后的.class文件放到%DOMNIO%/Data/Domino/servlet目录下面</p>
 * <p>然后通过http://%SERVER%/servlet/MailRedirectServlet访问即可</p>
 * <p>Copyright: Copyright (c) 2001 - 2004</p>
 * <p>Company: Beyond DayBreak Office</p>
 * <p>HomePage: http://202.101.111.1/123</p>
 * <p>E-Mail: YuLimin@163.net</p>
 * @author YuLimin
 * @version 1.0
 */

//package net.echochina.oa;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import lotus.domino.Document;
import lotus.domino.NotesException;
import lotus.domino.NotesFactory;
import lotus.domino.NotesThread;
import lotus.domino.Session;
import lotus.domino.View;

public class MailRedirectServlet extends HttpServlet
{
    final static String DB_NAMES = "Names.nsf";

    public MailRedirectServlet()
    {
    }

    public void init() throws ServletException
    {
    }

    public void destroy()
    {
    }

    public void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException
    {
        doPost(request,response);
    }

    public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException
    {
        String strFullName = request.getRemoteUser();
        String strMailFile = "";

        response.setContentType("text/html; charset=gb2312");
        ServletOutputStream out = response.getOutputStream();
        out.println("直接打开登录用户的邮件开始!<p>");
        out.println("登录的用户名为:" + strFullName + "<p>");

        if(strFullName == null || strFullName.equalsIgnoreCase("Anonymous"))
        {
            out.println("没有登录到Domino服务器!<p>");
            out.println("<script>document.location='/Names.nsf?Login&RedirectTo=/servlet/MailRedirectServlet';</script>");
        }
        else
        {
            NotesThread.sinitThread();
            Session session = null;
            View view = null;
            Document doc = null;
            try
            {
                session = NotesFactory.createSession();
                view = session.getDatabase(session.getServerName(),DB_NAMES).getView("People");
                doc = view.getDocumentByKey(getShortName(strFullName));
                if(doc != null)
                {
                    strMailFile = doc.getItemValueString("MailFile");
                    strMailFile = strMailFile.replace('//','/');
                    if(!strMailFile.toLowerCase().endsWith(".nsf"))
                    {
                        strMailFile += ".nsf";
                    }
                    out.println(strFullName + "用户的邮件为:" + strMailFile + "<p>");
                    String strMailURL = request.getScheme() + "://" + request.getServerName();
                    int strServerPort = request.getServerPort();
                    if(strServerPort != 80)
                    {
                        strMailURL += ":" + strServerPort;
                    }
                    strMailURL += "/" + strMailFile;
                    out.println("邮件地址为:" + strMailURL + "<p>");
                    out.println("<script>");
                    //out.println("alert('开始进入邮件')");
                    out.println("document.location='" + strMailURL + "'");
                    out.println("</script>");
                    //response.sendRedirect(strMailURL);
                    //response.encodeRedirectUrl(strMailURL)
                }
                else
                {
                    out.println("找不到 " + strFullName + " 的邮件文件!<p>");
                }
            }
            catch(NotesException e)
            {
                out.println(e.toString() + "<p>");
                e.printStackTrace();
                System.out.println(e.id + " " + e.text);
            }
            finally
            {
                try
                {
                    if(doc != null)
                    {
                        doc.recycle();
                        doc = null;
                    }
                    if(view != null)
                    {
                        view.recycle();
                        view = null;
                    }
                    if(session != null)
                    {
                        session.recycle();
                        session = null;
                    }
                }
                catch(Exception e)
                {
                    e.printStackTrace();
                }
                NotesThread.stermThread();
            }
        }
        out.close();
    }

    //取用户的短名!
    private String getShortName(String strTemp)
    {
        if(strTemp.indexOf("CN=") >= 0 && strTemp.indexOf("/") >= 0)
        {
            return strTemp.substring(3,strTemp.indexOf("/"));
        }
        else
        {
            return strTemp;
        }
    }

    public String getServletInfo()
    {
        return "登录Domino服务器后直接打开用户的邮件!";
    }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 7
    评论
在Lotus Domino 8上利用OSGi特性开发和部署插件程序具有许多优势和步骤。 首先,OSGi是一个用于构建可扩展和模块化应用程序的开源框架。在Lotus Domino 8中,你可以利用这个框架来开发和部署插件程序,以增强Domino服务器的功能。 开发插件程序首先需要安装Eclipse IDE,这是一种常用的Java开发环境。然后下载和安装IBM Lotus Expeditor插件开发工具包,这是Lotus Domino 8所使用的插件框架。在Eclipse IDE中创建插件项目,选择适当的项目类型和设置。 接下来,通过使用Eclipse IDE提供的工具,可以编写插件程序的代码。你可以使用Java编写代码,利用OSGi的概念创建各种模块化的组件。例如,你可以定义插件的扩展点和扩展,以及插件的依赖关系。 完成代码编写后,可以使用Eclipse IDE将插件程序打包成一个JAR文件。这个JAR文件包含了所有插件程序的代码和资源文件。 在部署插件程序到Lotus Domino 8之前,需要将JAR文件添加到Domino服务器的插件目录。然后,在Domino服务器的控制台中输入特定命令以启动插件程序。 通过这些步骤,你可以在Lotus Domino 8上利用OSGi特性开发和部署插件程序。这些插件程序可以增强Domino服务器的功能,并提供更多的定制化选项。同时,利用OSGi的模块化特性,插件程序可以独立开发和部署,不会干扰到Domino服务器的其他部分。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

YuLimin

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值