Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Java EE 综合讨论区  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 java mail 难题,帮忙看看吧? 跑了好多论坛.....
steelwoo





发贴: 2
积分: 0
于 2004-12-08 14:32 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
简单说就是怎么设定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"/>




SWT Designer v1.2.3 Released!

话题树型展开
人气 标题 作者 字数 发贴时间
2969 java mail 难题,帮忙看看吧? 跑了好多论坛..... steelwoo 1355 2004-12-08 14:32

flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   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