Topic: java mail 难题,帮忙看看吧? 跑了好多论坛.....

  Print this page

1.java mail 难题,帮忙看看吧? 跑了好多论坛..... Copy to clipboard
Posted by: steelwoo
Posted on: 2004-12-08 14:32

简单说就是怎么设定FOLDER 的连接保持的时间,让它在用户退出时才失效.

======>>>>>>>>>>>>>>>

怎么知道或设定 store.isConnected() 生存时间.我是这样做的,在每次页面跳转的时候判断 store.isConnected(); ,TRUE 时执行跳转,FALSE时转到登录页面. 结果总是过会儿再跳转的时候就到了登录页面....

我用的是两个SESSION..
部份代码:=======================================
MailUserBean中:
import javax.mail.Session;

InitialContext Itx = new InitialContext();
Context ctx = (Context)Itx.lookup("java:comp/env");
session = (Session)ctx.lookup("MailSession");
url = new URLName(ConstantsValue.PROTOCOL,
ConstantsValue.HOST_NAME, -1,
ConstantsValue.MBOX,
getUsername(),getPassword());
用这个获得Store store = session.getStore(url);

MailUserBean中:=============================
public boolean isLoggedIn()
{

return store.isConnected();
}

Servler中=====================================
import javax.servlet.http.HttpSession;

HttpSession session = request.getSession(true);
MailUserBean mailuser = (MailUserBean)session.getAttribute("mailuser");

if (mailuser.isLoggedIn())
getServletConfig().getServletContext().
getRequestDispatcher("/" + servletPath).
forward(request, response);
else
System.out.println("......Session was dated.....");
getServletConfig().getServletContext().
getRequestDispatcher("/index.jsp").
forward(request, response);

页面中:DisapprovedDisapproved
<jsp:useBean id="mailuser" scope="session" class="enprisemail.MailUserBean"/>


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923