精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2005-04-13
这是登录类: public class SkinUtil { public static Authorization login(HttpServletRequest request, HttpServletResponse response, String userName, String pwd);{ MemberManager mManager = new MemberManager();; Member member = mManager.getMember(userName,pwd);; Authorization auth = null; if (member != null);{ auth = new Authorization(member.getId();,member.getMembername(););; HttpSession session = request.getSession();; session.setAttribute("Member_Auth",auth);; } return auth; } public static Authorization getAuth(HttpServletRequest request, HttpServletResponse response);{ HttpSession session = request.getSession(false);; Authorization auth = (Authorization);session.getAttribute("Member_Auth");; if (auth != null);{ return auth; }else{ return null; } } public static boolean isUserExist(String userName);{ MemberManager mManager = new MemberManager();; Member member = mManager.getMember(userName);; if (member == null);{ return false; }else{ return true; } } public static void logout(HttpServletRequest request, HttpServletResponse response);{ HttpSession session = request.getSession();; session.removeAttribute("Member_Auth");; } } 下面是JSP页面: Authorization auth = (Authorization);session.getAttribute("Member_Auth");; if (auth == null);{ out.println("<script> top.location.href=\"login.jsp\"; </script>");; return; } 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2005-04-13
看错了,
session应该是失效的。 你需要在具体的描述一下,比如你的取权限的jsp是什么从跳转哪里来的 |
|
返回顶楼 | |
发表时间:2005-04-13
我没有写COOKIE啊,代码里你也看见了;如果我将SESSION。SETATTRIBUTE(“MEMBER_AUTH”,AUTH);这段代码写入JSP页面里,结果也是一样的。
|
|
返回顶楼 | |
发表时间:2005-04-13
我也碰到这个问题了,我用的是tapestry,把用户信息保存在Visit对象中,结果tomcat关闭而不关闭当前打开的ie,用户信息依然有效,后来我又写到session中
效果还是一样.关注... |
|
返回顶楼 | |
发表时间:2005-04-13
tomcat/resin/jetty等大部分的servlet container都会把session序列化到硬盘, 重起以后, 客户端的session id没有改变, 还能重新取得.
|
|
返回顶楼 | |
发表时间:2005-04-14
那要如何设置啊?
|
|
返回顶楼 | |
发表时间:2005-04-14
偶没有用过tomcat, 查文档, 或者去mail list问, 或者召唤tomcat达人......
|
|
返回顶楼 | |
发表时间:2005-04-14
把tomcat下的work目录删除试一下看看.
|
|
返回顶楼 | |
发表时间:2005-04-14
仔细看了下tomcat的server.xml
To clear sessions from the Store, set maxActiveSessions, maxIdleSwap, and minIdleBackup all to -1, saveOnRestart to false, then restart Catalina. <Manager className="org.apache.catalina.session.PersistentManager" debug="0" saveOnRestart="false" maxActiveSessions="-1" minIdleSwap="-1" maxIdleSwap="-1" maxIdleBackup="-1"> <Store className="org.apache.catalina.session.FileStore"/> </Manager> |
|
返回顶楼 | |
发表时间:2005-04-14
HttpSession session = null ; session = request.getSession();; boolean isNew = session.isNew();; if (!isNew);{ session.removeAttribute("Author什么的,我没写全");; session = request.getSession(true);; } session.setMaxInactiveInterval(3600*12);; 在serlvet里加上这么一段试试 |
|
返回顶楼 | |